I am trying to get the src of an image, however, it does not find the element of it does not filter to the image I need.
I have tried a couple of different xpaths and css selector including:
imgsrc = driver.find_element(By.CSS_SELECTOR, 'button[class="pv-top-card-profile-picture__image pv-top-card-profile-picture__image--show ember-view"]')
#imgsrc = driver.find_element(By.XPATH, "//img[@class='pv-top-card-profile-picture pv-top-card-profile-picture']")
That does not find the element.
imgsrc = driver.find_element(By.XPATH, "[//img[contains(@src, 'profile-displayphoto')]")
Is too broad and finds the incorrect image.
The html is as follows:
<div class="pv-top-card__non-self-photo-wrapper ml0">
<button class="pv-top-card-profile-picture pv-top-card-profile-picture__container display-block
pv-top-card__photo presence-entity__image EntityPhoto-circle-9
" type="button">
<img width="200" title="" src="https://media.licdn.com/dms/image/C4E03AQEW8FzkdjFD-w/profile-displayphoto-shrink_400_400/0/1516275678440?e=1683158400&v=beta&t=vmGZHtwkrttxt85prjTTySrnybP7L6lX858TpFgtWaQ" height="200" alt="" id="ember818" class="pv-top-card-profile-picture__image pv-top-card-profile-picture__image--show ember-view">
<!---->
<!---->
</button>
<div class="presence-entity__indicator presence-entity__indicator--size-9 presence-indicator
hidden
presence-indicator--size-9">
<span class="visually-hidden">
Status is offline
</span>
</div>
</div>