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("https://www.edureka.co/");
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,090 points
7,439 views

1 answer to this question.

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,460 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 29, 2018 in Selenium by bug_seeker
• 15,510 points
1,938 views
+2 votes
1 answer
0 votes
1 answer
0 votes
2 answers

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,500 points
13,687 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,149 views
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,910 points
7,229 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,880 views
0 votes
1 answer

How to use Enter/Return Key in Selenium

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

answered Apr 18, 2018 in Selenium by Meci Matt
• 9,460 points
2,877 views
+10 votes
17 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,360 points
198,021 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP