Home > Enterprise >  Splinter Python ElementDoesNotExist for is_visible()
Splinter Python ElementDoesNotExist for is_visible()

Time:02-06

In my code I have following line:

browser.find_by_css(business_role_expand).is_visible(1000)

According to the documentation, the code should wait maximum of 1000s for the element specified by the CSS to load and be visible. If not, it will return "False". However instead I get this error:

splinter.exceptions.ElementDoesNotExist: no elements could be found with css "div.panel:nth-child(4) > div:nth-child(1) > a:nth-child(1)"

Can anyone advise me? I don't understand why this happens. I'm using Firefox driver.

CodePudding user response:

This error...

splinter.exceptions.ElementDoesNotExist: no elements could be found with css "div.panel:nth-child(4) > div:nth-child(1) > a:nth-child(1)"

...implies that no element exists within the DOM Tree which can be identified by the css_selector:

div.panel:nth-child(4) > div:nth-child(1) > a:nth-child(1)

As the element itself doesn't exist, there is no question of waiting for the presence, visibility or interactibility of the element even with wait_time


Solution

Try to construct a locator strategy which identifies the element uniquely within the HTML DOM.

CodePudding user response:

It's impossible to say without being able to see the page but a couple scenarios come to mind.

  1. Your locator is off somehow. We can't help fix it without a link to the page or the relevant HTML.

  2. Your locator is correct but the page needs to be scrolled or otherwise manipulated to cause the element to appear. Again, we can't help without seeing the page.

  • Related