Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bvlion
Created March 14, 2017 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bvlion/bebfee66cb60f272d9eb97c05597d2f1 to your computer and use it in GitHub Desktop.
Save bvlion/bebfee66cb60f272d9eb97c05597d2f1 to your computer and use it in GitHub Desktop.
// 指定のウィンドウサイズに変更
int width = 480;
int height = 600;
driver.manage().window().setSize(new Dimension(width, height));
// 最大化
/* driver.manage().window().maximize(); */
if (isFirefox) {
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("general.useragent.override", "ここに設定したいUAの文字列"); // "general.useragent.override"は固定。
WebDriver driver = new FirefoxDriver(profile);
} else {
System.setProperty("webdriver.chrome.driver", "./driver/chromedriver.exe"); // ドライバーのパス
ChromeOptions options = new ChromeOptions();
options.addArguments("--user-agent=ここに設定したいUAの文字列");
WebDriver driver = new ChromeDriver(options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment