0

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.

eXPRESS
  • 425
  • 2
  • 4
  • 19

2 Answers2

0

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.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I understand, but it should not happen right? If the wait_time for is_visible(1000) is 1000 than it should just keep polling until it sees it, no? – eXPRESS Feb 03 '23 at 13:06
  • True, but it would wait for visibility later. First the element itself should be present within the DOM and identified by a locator, where as the the python client is complaining about the element being _`ElementDoesNotExist`_. – undetected Selenium Feb 03 '23 at 13:10
  • 1
    I see, so the locator strategy that you are proposing is the way how to wait for "existence" of the element instead of "visibility"? My goal is to wait for "the page load". Thank you for your advice – eXPRESS Feb 03 '23 at 13:13
0

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.

JeffC
  • 22,180
  • 5
  • 32
  • 55