0

I'm trying to click links on a website, there's a full page of them. I tried using the is_displayed() option, I came back "true" but then still gave me this error. I've encountered this error before on other projects, its because selenium doesn't see the link. I tried putting a scroll down option in the code but that only works so many times as the page down ends up scrolling too far.

What other options do I have to get the link visible to click on?

Code:

href1 = driver.find_element_by_xpath("//*[@id='divDesktopResults']//div//div//div//a[@href='" + link + "']")

if (href1.is_displayed()):
    print('true')
    href1.click()
else:
    print('False')

Error:

selenium.common.exceptions.WebDriverException: Message: unknown error: Element <a class="popimg" data-toggle="popover" style="text-decoration:underline;margin-right:20px;" data-content="<img style='max-width:250px;' src='/Home/GetPng?ID=D218098469' ></a>" data-html="true" data-trigger="hover" href="#pdfviewer?ID=D218098469">...</a> is not clickable at point (441, 514). Other element would receive the click: <div class="row">...</div>
 (Session info: chrome=66.0.3359.181)
 (Driver info: chromedriver=2.38.552522   (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.16299 x86_64)

Edit:

Solved another way, put all the links in an array and used driver.get instead of clicking the link.

1 Answer 1

0

Selenium is complaining not that the link can't be seen, but that something else is essentially on top of the link. Clicking on the screen where the link is would instead click on the "row" div. This would imply a CSS error where you have multiple elements one on top of the other. You could potentially confirm this by giving the link a really high Z value so that it sits on top of everything else and re-run your test.

Sign up to request clarification or add additional context in comments.

5 Comments

How would I give the link a really high Z value. You mentioned click the row, isnt the a tag the link itself rather than the div tag?
Yes, but selenium finds the a tag, and returns x,y coordinates where it resides. Then it essentially moves a virtual mouse over those coordinates and 'clicks' them. Your error message is that clicking on those coordinates would click that div instead, because it's on top of the anchor tag. For info on z index go here: CSS z-index property - W3Schools Online Web Tutorials w3schools.com/cssref/pr_pos_z-index.asp
Am I able to change the Z value with python or selenium?
You could possibly hack it, but the easiest way would be to modify the HTML.
Sounds good - make sure you edit your question to include how you solved it. That way if people have the same issue they can see your solution.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.