java - Selenium WebDriver takes a lot of time to find element in iframe -


I am using Webdriver 2.39.0 and FF 26 (I also tried with 27) and the following HTML is:

  & lt; Div id = "saroiaj_harta" & gt; & Lt; Iframe id = "ifr_layout_prepay" scrolling = "no" frameborder = "0" src = "http://test-harta.ci.rmn.ro//layout/prepay/init/1/lat/45.738235215834/lon/21 2226 9 85 9 0278 / of_lat / 0 / of_lon / 0 / -mail address / 073074072061064061 / iZoom / 15 / caroiaj "& gt; & Lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div id = "map_container_2" & gt; & Lt; Div id = "map_container_1" & gt; & Lt; Div id = "map_container" class = "clearfix" & gt; & Lt; Div id = "map" class = "OLAM cessmap cursormafics" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt; & Lt; / Iframe & gt; & Lt; / Div & gt;  

I also have the following code, which should be an element with the "map" id within the iframe:

  Browser.Wit Element (By.id ("Ifr_layout_prepay)")); Driver.switchTo () frame ("ifr_layout_prepay") .; Browser.waitElement (By.id ("map")); Public Square Browser {Public Static Zero Waiting Element (By Locator) {WebDriverWait Wait = New WebDriverWait (Driver, 10); Wait.until (ExpectedConditions.visibilityOfElementLocated); }}  

What happens is that the test finds the iframe, switches into iframe, before it gets the 'map' element and continues with the other instructions 5 minutes before . I want to specify that it is hanging more than 10 seconds while trying to find 'map', I'm waiting.

That's why I do not know why this happens, anyone has any ideas before or any? Instead of using WebDriverWait, try just with your own waiting method.

  public static zero waiter nailttoopper (by) {int i = 0; While (! IELMENT display (by)) {Thread.sleep (100); If (++ i> 100) {break;  

You can find the isElementPresent method implementation.

Now try your flow something like the following.

  driver.switchTo () frame ("ifr_layout_prepay") .; MyWait.waitForAnElementToAppear (By.id ("map")); (By.id ("map"));  

Comments