Hey there! any question in your mind? Ask It Now!.

Popular Categories





Selenium: wait till load element in next page

+13 votes
115 views
asked in Software Testing by CaptSaltyJack (1,140 points)
edited by CaptSaltyJack
I have to click on a element which come on a page after loading page,So how can i wait till load element in next page?

1 Answer

+2 votes
answered by seleniumGuru Expert (4,570 points)
edited by seleniumGuru
 
Best answer

For webdriver wait till the load an element ,you can use implicitlyWait But i recommend you to use ExpectedConditions

implicitlyWait: driver.manage().timeouts().implicitlyWait(130, TimeUnit.SECONDS);

ExpectedConditions :    WebElement element = (new WebDriverWait(driver, 1)).until(ExpectedConditions.presenceOfElementLocated((By.ID(ELEMENT_ID_HERE))));

Enjoy!
commented by CaptSaltyJack (1,140 points)
Thanks ExpectedConditions works but can you tell me if i want to decide the time till then driver will wait?
commented by seleniumGuru Expert (4,570 points)
yah here WebElement element = (new WebDriverWait(driver, 3)).until(ExpectedConditions.presenceOfElementLocated((By.ID(ELEMENT_ID_HERE))));
here i have changed time 1 to 3 , so i think you got the point.
Enjoy!
commented by Himanshu Expert (5,940 points)
i also recommend you to use  ExpectedConditions

Related Questions

+1 vote
1 answer 539 views

Not a Member yet?

Ask to Folks Login

My Account
341 Folks are online
27 members and 314 guest online
Your feedback is highly appreciated