Showing posts with label screenshot in Selenium Webdriver. Show all posts
Showing posts with label screenshot in Selenium Webdriver. Show all posts

Friday, 4 July 2014

How to take a screenshot in Selenium Webdriver

code will help you how to take a snapshot in selenium webdriver.

Also one thing noticed is that sometimes “import org.openqa.selenium. TakesScreenshot;” this import don’t appear and you have to manually add this line to your code to make this work. import java.io.File;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class Chrome {
WebDriver driver;
@BeforeMethod
public void launchChrome()
{
System.setProperty(“webdriver.chrome.driver”, “E:\Harsimran-PC\workspace\chromedriver_win_26.0.1383.0\chromedriver.exe”);
driver = new ChromeDriver();
driver.get(“http://google.co.in”);
}
@Test
public void googleScreenshot()
{
try {
File scrnsht =((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// This is where magic happens FileUtils.copyFile(scrnsht, new
File(“e:\google_page.png”));
} catch (Exception e) {
e.printStackTrace();
}
}
@AfterTest
public void kill()
{
driver.close();
}
}

Usage of sql jdbc 4.0 driver

This post is related to using sql jdbc driver 4.0

If you are using sql jdbc driver then these are things to note and follow:
1) Download sqljdbc driver from http://www.microsoft.com/en-in/download/details.aspx?id=11774
2) Now if your jdk is 32-bit then set the 32-bit driver path to your system property or 64-bit if your jdk is 64-bit
3) Now if you are using integrated security then copy the authorization .dll to your system32 folder and set that property to your system path as well.
4) If you still get issues with it then let us know