Created
November 11, 2012 14:49
-
-
Save siguremon/4055111 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package SeleniumSample; | |
import org.apache.commons.io.FileUtils; | |
import org.openqa.selenium.*; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
import org.openqa.selenium.firefox.FirefoxDriver; | |
import org.openqa.selenium.ie.InternetExplorerDriver; | |
import org.openqa.selenium.support.ui.ExpectedConditions; | |
import org.openqa.selenium.support.ui.WebDriverWait; | |
import java.io.File; | |
import java.io.IOException; | |
import java.sql.Driver; | |
import java.util.concurrent.TimeUnit; | |
/** | |
* Hello world! | |
* | |
*/ | |
public class App | |
{ | |
public static void main( String[] args ) throws IOException { | |
System.out.println( "Hello World!" ); | |
WebDriver ffdriver = new FirefoxDriver(); | |
ffdriver.manage().window().setSize(new Dimension(1500, 1000)); | |
testYahoo(ffdriver, "c:\\Users\\siguremon\\ff.png"); | |
ffdriver.quit(); | |
WebDriver iedriver = new InternetExplorerDriver(); | |
iedriver.manage().window().setSize(new Dimension(1506, 1000)); | |
testYahoo(iedriver, "c:\\Users\\siguremon\\ie.png"); | |
iedriver.quit(); | |
WebDriver chdriver = new ChromeDriver(); | |
chdriver.manage().window().setSize(new Dimension(1502, 1000)); | |
testYahoo(chdriver, "c:\\Users\\siguremon\\ch.png"); | |
chdriver.quit(); | |
} | |
public static void testYahoo(WebDriver driver, String scname) { | |
driver.get("http://yahoo.co.jp"); | |
takeScreenshot(driver, scname); | |
} | |
public static void takeScreenshot(WebDriver driver, String name) { | |
File srcFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); | |
try { | |
FileUtils.copyFile(srcFile, new File(name)); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment