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

Popular Categories

Selenium: wait till load element in next page

+13 votes
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))));

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.
commented by Himanshu Expert (5,940 points)
i also recommend you to use  ExpectedConditions

Related Questions

+1 vote
1 answer 698 views

Not a Member yet?

Ask to Folks Login

My Account
251 Folks are online
0 members and 251 guest online
Your feedback is highly appreciated