How to locate this kind of element with Selenium
<p>I'm trying to learn how to make script in python with selenium. Most of the time I was practising with "static element" but now I want to select some elements which have a dynamic id but the problem is that their id don't have a partial static part.</p>

<p>However they have another "id", static this time but I don't know how to use it in Python with selenium I have tried two different things but Selenium is unable to find this element</p>

<p>This a part of the element:</p>

<pre><code>&lt;div class="table-cell show-plus" ng-class="{'show-plus': !user.deleted &amp;amp;&amp;amp; (authentication.user.isManager || user.isMe) &amp;amp;&amp;amp; (!group.isExchange || !ctrl.isPast(day)), 'no-events': !_events.length, 'is-today': day === ctrl.todayString}" ng-repeat="day in ctrl.currentDays" ng-click="ctrl.addShift(user, day, false, group.grouping, group.isExchange, group.key)" lvl-drop-target="true" on-drop="ctrl.dropped(dragEl, dropEl, event, 'week')" data-user-id="30308" data-is-exchange="false" data-shift-date="2016-09-29" id="5aa270ea-180f-2861-c97a-506c76cee386"&gt;&lt;!----&gt;&lt;div data-shift-id="134514" data-is-exchange="false" ng-repeat="event in ::(_events = (user.events[day] | filter:ctrl.filterOutMultiday | orderBy:['sort', 'dtstart'])) track by event.key" lvl-draggable="true" augment-draggable="" class="shift s12B835 published can-be-selected" ng-class="::{
              leave: event.type === 'leave',
              staging: event.status === 'planning',
              cancelled: event.cancelled,
              openend: event.isOpenEnded,
              published: event.status === 'published',
              unpublished: event.status !== 'published',
              unavailability: event.type === 'availability',
              'can-be-selected': event.canBeSelected
             }" draggable="true" id="c9d08710-daef-cdf7-9d7b-c4ceb13541a6"&gt;&lt;!----&gt;&lt;div class="shift-selection" ng-click="ctrl.stopEventPropagation($event)" ng-if="::event.canBeSelected"&gt;&lt;div class="checkmark-wrapper"&gt;&lt;label class="checkmark"&gt;&lt;input type="checkbox" ng-model="ctrl.selectedEvents[event.id]" ng-change="ctrl.selectionChanged()" class="ng-pristine ng-untouched ng-valid ng-empty"&gt; &lt;span&gt;&lt;/span&gt;&lt;/label&gt;&lt;/div&gt;&lt;/div&gt;&lt;!----&gt;&lt;div class="shift-details" ng-click="ctrl.openShift(event, group.isExchange, $event)" ng-class="{'right-icon': event.showOfferedShiftIcon || event.showAvailableShiftIcon || event.showTimeoffIcon}"&gt;&lt;div class="ellipsis" title="9:00A - 5:00P â¢ 8H"&gt;9:00A - 5:00P â¢ 8H &lt;img style="margin-top:-2px" ng-show="event.tagId &amp;amp;&amp;amp; event.status !== 'planning'" src="/assets/svg/Icons/16/shift-repeat-white-8afc52.svg" class="ng-hide"&gt; &lt;img style="margin-top:-2px" ng-show="event.tagId &amp;amp;&amp;amp; event.status === 'planning'" src="/assets/svg/Icons/16/shift-repeat-gray-6d0e14.svg" class="ng-hide"&gt;&lt;/div&gt;&lt;div class="ellipsis duration" ng-show="event.position"&gt;Design &lt;span class="show-on-collapsed"&gt;â¢ Carl Fairclough&lt;/span&gt;&lt;/div&gt;&lt;div class="ellipsis duration ng-hide" ng-show="!event.position"&gt;Carl Fairclough&lt;/div&gt;&lt;span class="shift-details-status ng-hide" ng-show="event.showOfferedShiftIcon"&gt;&lt;img src="/assets/svg/Icons/24/shift-offer-white-cce33c.svg"&gt; &lt;/span&gt;&lt;span class="shift-details-status ng-hide" ng-show="event.showAvailableShiftIcon"&gt;&lt;img src="/assets/svg/Icons/24/shift-available-white-c55aba.svg"&gt; &lt;/span&gt;&lt;span class="shift-details-status ng-hide" ng-show="event.showTimeoffIcon"&gt;&lt;img src="/assets/svg/Icons/24/shift-timeoff-white-0cab28.svg"&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;!----&gt;&lt;/div&gt;

&lt;div data-shift-id="134514" data-is-exchange="false" ng-repeat="event in ::(_events = (user.events[day] | filter:ctrl.filterOutMultiday | orderBy:['sort', 'dtstart'])) track by event.key" lvl-draggable="true" augment-draggable="" class="shift s12B835 published can-be-selected" ng-class="::{
              leave: event.type === 'leave',
              staging: event.status === 'planning',
              cancelled: event.cancelled,
              openend: event.isOpenEnded,
              published: event.status === 'published',
              unpublished: event.status !== 'published',
              unavailability: event.type === 'availability',
              'can-be-selected': event.canBeSelected
             }" draggable="true" id="c9d08710-daef-cdf7-9d7b-c4ceb13541a6"&gt;&lt;!----&gt;&lt;div class="shift-selection" ng-click="ctrl.stopEventPropagation($event)" ng-if="::event.canBeSelected"&gt;&lt;div class="checkmark-wrapper"&gt;&lt;label class="checkmark"&gt;&lt;input type="checkbox" ng-model="ctrl.selectedEvents[event.id]" ng-change="ctrl.selectionChanged()" class="ng-pristine ng-untouched ng-valid ng-empty"&gt; &lt;span&gt;&lt;/span&gt;&lt;/label&gt;&lt;/div&gt;&lt;/div&gt;&lt;!----&gt;&lt;div class="shift-details" ng-click="ctrl.openShift(event, group.isExchange, $event)" ng-class="{'right-icon': event.showOfferedShiftIcon || event.showAvailableShiftIcon || event.showTimeoffIcon}"&gt;&lt;div class="ellipsis" title="9:00A - 5:00P â¢ 8H"&gt;9:00A - 5:00P â¢ 8H &lt;img style="margin-top:-2px" ng-show="event.tagId &amp;amp;&amp;amp; event.status !== 'planning'" src="/assets/svg/Icons/16/shift-repeat-white-8afc52.svg" class="ng-hide"&gt; &lt;img style="margin-top:-2px" ng-show="event.tagId &amp;amp;&amp;amp; event.status === 'planning'" src="/assets/svg/Icons/16/shift-repeat-gray-6d0e14.svg" class="ng-hide"&gt;&lt;/div&gt;&lt;div class="ellipsis duration" ng-show="event.position"&gt;Design &lt;span class="show-on-collapsed"&gt;â¢ Carl Fairclough&lt;/span&gt;&lt;/div&gt;&lt;div class="ellipsis duration ng-hide" ng-show="!event.position"&gt;Carl Fairclough&lt;/div&gt;&lt;span class="shift-details-status ng-hide" ng-show="event.showOfferedShiftIcon"&gt;&lt;img src="/assets/svg/Icons/24/shift-offer-white-cce33c.svg"&gt; &lt;/span&gt;&lt;span class="shift-details-status ng-hide" ng-show="event.showAvailableShiftIcon"&gt;&lt;img src="/assets/svg/Icons/24/shift-available-white-c55aba.svg"&gt; &lt;/span&gt;&lt;span class="shift-details-status ng-hide" ng-show="event.showTimeoffIcon"&gt;&lt;img src="/assets/svg/Icons/24/shift-timeoff-white-0cab28.svg"&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
</code></pre>

<p>The only things for me to pick this element is to use : </p>

<pre><code>&gt; data-shift-id="134514"
</code></pre>

<p>I have tried different ways wwith id and xpath but same result at the end: "Unable to locate this element"</p>

<p>Do you have any ideas please? </p>

<p>You can build a cssSelector using attribute like this:</p>

<pre><code>driver.find_element_by_css_selector("Yourtag[attributeName='Your AttributeValue']");
</code></pre>

<p>For your specific case use below code snippet:</p>

<pre><code>driver.find_element_by_css_selector("div[data-shift-id='134514']");
</code></pre>

python selenium