Selenium: Selenium does not detect element even when the element is present on the page

Created on 2 Apr 2018  路  5Comments  路  Source: SeleniumHQ/selenium

Meta -

OS:
Window 7/Windows 10

Selenium Version:
2.47 - 3.8

Browser:
Google Chrome/Firefox

Browser Version:
gc : latest
ff 53 - ff 58

Expected Behavior -

Selenium Should detect the element in all the cases if it is present

Actual Behavior -

Selenium does not detect the element randomly (It can be seen on screenshot)

Steps to reproduce -

My Wait statement fails when searching for the presence of element on page

I am using Selenium with Robotframework. What I observe that many time my "Waits" fails stating the reason that element is not present on the page. But screenshot captured shows element is there. Same code works ok If I run it again. This is observed especially when we run the code on slower environment or old VM. I tried increasing implicit wait to 3seconds.

Some notes

  • HTML page remains consistent. No extra iFrame is added/removed
  • We tried increasing explicit timeout till 180 seconds and implicit timeout to 3s
  • I am using link= and xpath to locate the elements. Behavior is observed for all types of locators
  • There are no duplicate match of locators and they are always visible
  • I tried the different combinations of Selenium, Browser/ Versions, and Driver since last 6 months but this is still there

Some help of tip will be a great help

R-awaiting answer

All 5 comments

We can't do anything without a concise reproducible test case. Please make sure to use selenium in your reproducible test case and not robot framework. See CONTRIBUTING.md

Hi @lmtierney ,
Steps to produce issue are simple. Use any wait statement on any website with on slow machine and slow bandwidth. However, it will not reproduce every time. Due to this reason, I kept myself from posting the issue here. But doing that now as I met many people who are facing this problem. Please see if anything can be done.

About RobotFramework,
Just like any framework in Java, this one is in python which uses selenium jar.

Please provide a concise reproducible test case instead of a narrative description.
If the issue is random, we can run this scenario in a loop until it occurs.

If you just have a really slow machine increase timeouts to 10 or 20 seconds, may be 3 seconds is not enough.

Hi @barancev,
Yes, you are right we can put this inside loop and run it on a slow machine and the slow network,

About your suggestion on implicit timeout. I think 3 seconds is more than enough as wait statement has already taken 180 seconds to wait. Still, I'll try it will higher values.

Closing the issue as there is no reproduction scenario.

Was this page helpful?
0 / 5 - 0 ratings