|
package Error_png;
import org.junit.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.io.*;
import org.apache.commons.io.FileUtils;
import java.util.concurrent.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
public class Error_png {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
public String a;
@Before
public void setUp() throws Exception
{
driver = new FirefoxDriver();
baseUrl = "http://www.baidu.com";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testTakesScreenshot()throws Exception{
driver.get(baseUrl+"/login/index");
try{
driver.findElement(By.id("kwddd")).sendKeys("Selenium webDriver");
}
catch(Exception e)
{
File srcFile=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(srcFile, new File("C:\\Users\\Administrator\\workspace\\ErpOfAutomation\\src\\Error_png\\3.png"));
}
}
@After
public void tearDown() throws Exception
{
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
}