2

I'm trying to wait till the preloader appears on the website for that I'm using ExpectedConditions.invisibilityOfElementLocated but initially when I was locating preloader through the class name "DarkBg", the explicit wait didn't wait for the preloader to get invisible but later when I located through Id then the explicit wait worked and waited till the loader disappeared.

I've attached the loader image along with its source code. I want to know why the explicit wait through classname locator didn't work?

Preloader

user2044296
  • 504
  • 1
  • 7
  • 18
  • How many occurrences of class DarkBg are on your page? – SiKing Jun 11 '19 at 21:41
  • As mentioned by @SiKing, Have you got a chance to check how many elements are there on the page with the class `DarkBg`. Possibility is there may be another element with the same class name. – supputuri Jun 11 '19 at 22:25
  • There is only one instance of Class DarkBg, which I found using System.out.println(driver.findElements(By.className("DarkBg")).size()); – user2044296 Jun 12 '19 at 04:30

1 Answers1

1

While using ExpectedConditions invisibilityOfElementLocated() with the classname DarkBg, the element seems to be a <div> node which seems to be the parent of the actual overlay in the form of the <img> node. This <div> node includes only the style height and may be either bigger then the Viewport (or out of the Viewport) and can be the possible reason behind Selenium unable to interact with it:

div_img

Where as the <img> tag seems to be have all the required style attributes present to be within the Viewport and interactable in the form of width, height, top, etc.

Hence Selenium easily detects it.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352