How to pause for few seconds in Selenium?

0 votes

I want to wait for something to load and then take it's screenshot and save it.

Below is the code:

WebDriver driver = new FirefoxDriver();
driver.get("http://www.abc.com");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
try {
    File scr = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
    FileUtils.copyFile(scr,new File("/Desktop/image.png"));
} catch (Exception e) { 
       e.printStackTrace(); 
}
driver.close();

The page is not waiting for me, is there any method to get the driver/page to wait for few seconds?

Jul 6, 2018 in Selenium by Johnathon
• 9,070 points
379 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

you can locate an element that loads after the initial page loads and then makes Selenium wait till it finds that element, as shown below:

WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("id")));
answered Jul 6, 2018 by Meci Matt
• 9,400 points

Related Questions In Selenium

0 votes
1 answer

How to wait for the webpage to load in selenium using java

Firstly, when you launch a web application, ...READ MORE

answered Aug 28, 2018 in Selenium by bug_seeker
• 15,300 points
97 views
+2 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
159 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
545 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
145 views
0 votes
1 answer

How to use Enter/Return Key in Selenium

You can use the below code: import org.openqa.selenium.Keys WebElem ...READ MORE

answered Apr 18, 2018 in Selenium by Meci Matt
• 9,400 points
325 views
+9 votes
13 answers

How to automate gmail login process using selenium webdriver in java?

Check the below code: Here is the working ...READ MORE

answered Apr 24, 2018 in Selenium by Vardy
• 2,280 points
42,180 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.