com.sunnydsouza.testframework.layers.selenium.browser.ChromeProfile Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of testframework Show documentation
Show all versions of testframework Show documentation
Generic frameowrk with different standalone layers for reporting,logging,test execution and test data management.
package com.sunnydsouza.testframework.layers.selenium.browser;
import java.io.File;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.chrome.ChromeOptions;
public class ChromeProfile {
public static void main(String[] args) {
//System.setProperty("webdriver.chrome.driver", "./chromedriver.exe");
ChromeDriverService chSvc = new ChromeDriverService.Builder()
.usingDriverExecutable(new File("./chromedriver.exe")).usingAnyFreePort().build();
ChromeOptions chOption = new ChromeOptions();
/**
* "user-data-dir = profilepath" --to open profile
* "--start-maximized" for maximize the browser
*/
chOption.addArguments("user-data-dir = Our Profile Path");
chOption.addArguments("--start-maximized");
/*ChromeOptions options = new ChromeOptions()
options.addExtensions(new File("/path/to/extension.crx"))
options.setBinary(new File("/path/to/chrome"));
// For use with ChromeDriver:
ChromeDriver driver = new ChromeDriver(options);
// For use with RemoteWebDriver:
RemoteWebDriver driver = new RemoteWebDriver(
new URL("http://localhost:4444/wd/hub"),
new ChromeOptions());*/
WebDriver driver = new ChromeDriver(chSvc, chOption);
driver.quit();
}
}