2

I ran into a similar problem described here: Selenium - can't find visible element until HTML is inspected? But the solution indicated there did not help me.

There's a website that has the following dropbox (I can see them when I inspect the page): enter image description here

No error is raised when I attempt to switch to the desired frame, no elements are found with id = UIFormControl-5.

So after inspecting the dropbox (id = UIFormControl-5) and doing no other change whatsoever, the elements are there, as if the mere act of looking at the source code of the webpage changed the outcome of the result. What could possibly be happening here?

I'm using the java selenium code

            driver.switchTo().frame(driver.findElement(By.cssSelector("iframe.flex-grow-1")));
            wait.until(ExpectedConditions.presenceOfElementLocated(By.id("UIFormControl-5")));
            driver.findElement(By.id("UIFormControl-5")).click();
0buz
  • 3,443
  • 2
  • 8
  • 29
165maikl
  • 21
  • 1

1 Answers1

0

Induce WebDriverWait() and wait for frameToBeAvailableAndSwitchToIt()

Induce WebDriverWait() and wait for elementToBeClickable() and then click.

new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector("iframe.flex-grow-1")));
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.id("UIFormControl-5"))).click();
KunduK
  • 32,888
  • 5
  • 17
  • 41
  • Are you sure Id is not dynamic? – KunduK Feb 19 '20 at 12:10
  • Not dynamic, 100% – 165maikl Feb 19 '20 at 12:32
  • org.openqa.selenium.TimeoutException: Expected condition failed: waiting for presence of element located by: By.id: UIFormControl-5 To localize the problem, I did the following steps: 1. open URL in Chrome 2. open frame with dropbox 3. open DevTools - Console 4. send $$ ("#UIFormControl-5") 5. nothing found 6. inspect the dropbox 7. send $$ ("#UIFormControl-5") to console 8. 1 element found! – 165maikl Feb 19 '20 at 13:15
  • is that url public?can it be possible to share? – KunduK Feb 19 '20 at 13:30