I have an element that selenium doesn't recognize sometimes.
I'm using implicitlyWait
of 10 seconds and when i'm runing the test sometimes it passed succesfully and the element is recognized, and sometimes it failes with error "No such element".
I tried to change the wait time to 20 seconds but it dosen't matter
Asked
Active
Viewed 92 times
0

Lior p
- 45
- 6
-
Does that element appear in the screen? I mean "the screen" you see, not in the code – ToraCode Jan 04 '19 at 08:33
-
Yes, he exist all the time, I'm running the same test all the time – Lior p Jan 04 '19 at 09:15
-
Does the web apply dynamic loading or lazy loading? Let your sel smooth run from bottom to top to find it in 10 seconds. May use While Loop – ToraCode Jan 04 '19 at 09:31
-
The web apply in less then 10 seconds, i'm seeing the element on the page but selenium doesn't recognize him – Lior p Jan 04 '19 at 10:14
-
Waiting is not the solution, make your sel browser run bottom to top serveral times to find out the issue. This was my solution in the past. If it still don't recognize, try reload and find again if you sure the web have it. – ToraCode Jan 04 '19 at 10:27
2 Answers
0
try using explicit wait :
WebDriverWait wait = new WebDriverWait(webDriver,60); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div/div/div/div/div[1]/div/div/a/i")));

sp324
- 285
- 2
- 20
-
-
@Liorp please don't mix implicit and explicit waits for reference please checkout https://stackoverflow.com/questions/15164742/combining-implicit-wait-and-explicit-wait-together-results-in-unexpected-wait-ti#answer-15174978 – anurag0510 Jan 04 '19 at 10:35
0
I also faced this issue one time and I was facing this issue because I was was trying to select some option in the sub-menus using click to the main menu and then the sub-menu. When used Actions class, the issue was resolved. This could be an issue for you as well.

Neha
- 316
- 1
- 4
- 16