The problem is that I can't figure out how to follow a link. The link goes to the page I want when I click on the image, and the desired page opens in a new tab. It's difficult to describe, it's easier to understand from the attached code
<div class="css-1owz1l2">
<span class=" lazy-load-image-background blur lazy-load-image-loaded" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; border-radius: 4px; cursor: pointer; object-fit: cover; display: flex;">
<img style="height: 100%; width: 100%; object-fit: cover; border-radius: 4px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0%;" src="https://public.nftstatic.com/static/nft/zipped/9082041d35194edd87f9078dc9440f7b_zipped.jpeg" sx="[object Object]">
</span>
</div>
CodePudding user response:
You can extract the link from src
attribute of img
element as following.
In case "css-1owz1l2" class is unique you can do this:
img = driver.find_element_by_xpath("//div[@class='css-1owz1l2']//img")
link = img.org.get_attribute("src")
Now you can use this link like this:
driver.get(link)
Or by any other way
CodePudding user response:
You can trying catching the image element and clicking on it directly:
# catching the image element
image = driver.find_element_by_xpath("//div[@class='css-1owz1l2']//img")
image.click()