use of com.microsoft.edge.seleniumtools.EdgeOptions in project seleniumRobot by bhecquet.
the class TestEdgeCapabilityFactory method testCreateEdgeCapabilitiesWithoutDefaultProfileGrid.
@Test(groups = { "ut" })
public void testCreateEdgeCapabilitiesWithoutDefaultProfileGrid() {
when(config.getMode()).thenReturn(DriverMode.GRID);
MutableCapabilities capa = new EdgeCapabilitiesFactory(config).createCapabilities();
// check 'edgeProfile' is not set as not requested, and no option added
Assert.assertNull(capa.getCapability("edgeProfile"));
Assert.assertFalse(((Map<String, List<String>>) (((EdgeOptions) capa).asMap().get(EdgeOptions.CAPABILITY))).get("args").toString().contains("--user-data-dir=/home/user/profile"));
}
use of com.microsoft.edge.seleniumtools.EdgeOptions in project seleniumRobot by bhecquet.
the class TestEdgeCapabilityFactory method testCreateEdgeCapabilitiesDefaultProfile.
@Test(groups = { "ut" })
public void testCreateEdgeCapabilitiesDefaultProfile() {
when(config.getEdgeProfilePath()).thenReturn("default");
when(config.getMode()).thenReturn(DriverMode.LOCAL);
MutableCapabilities capa = new EdgeCapabilitiesFactory(config).createCapabilities();
// a user data dir is configured
Assert.assertNotEquals(((Map<?, ?>) (((EdgeOptions) capa).asMap().get(EdgeOptions.CAPABILITY))).get("args").toString(), "[--disable-translate, --disable-web-security, --no-sandbox, --disable-site-isolation-trials, --disable-features=IsolateOrigins,site-per-process, --user-data-dir=/home/foo/edge]");
Assert.assertTrue(((Map<?, ?>) (((EdgeOptions) capa).asMap().get(EdgeOptions.CAPABILITY))).get("args").toString().startsWith("[--disable-translate, --disable-web-security, --no-sandbox, --disable-site-isolation-trials, --disable-features=IsolateOrigins,site-per-process, --user-data-dir="));
}
use of com.microsoft.edge.seleniumtools.EdgeOptions in project seleniumRobot by bhecquet.
the class EdgeCapabilitiesFactory method getDriverOptions.
@Override
protected MutableCapabilities getDriverOptions() {
EdgeOptions options = new EdgeOptions();
if (webDriverConfig.getUserAgentOverride() != null) {
options.addArguments("--user-agent=" + webDriverConfig.getUserAgentOverride());
}
options.addArguments("--disable-translate");
options.addArguments("--disable-web-security");
options.addArguments("--no-sandbox");
options.addArguments("--disable-site-isolation-trials");
options.addArguments("--disable-features=IsolateOrigins,site-per-process");
if (webDriverConfig.getEdgeOptions() != null) {
for (String option : webDriverConfig.getEdgeOptions().split(" ")) {
options.addArguments(option);
}
}
if (webDriverConfig.isHeadlessBrowser()) {
logger.info("setting edge in headless mode");
options.addArguments("--headless");
options.addArguments("--window-size=1280,1024");
options.addArguments("--disable-gpu");
}
if (webDriverConfig.getMode() == DriverMode.LOCAL) {
setLogging();
}
if (webDriverConfig.getAttachExistingDriverPort() != null) {
options.setExperimentalOption("debuggerAddress", "127.0.0.1:" + webDriverConfig.getAttachExistingDriverPort());
} else {
// issue #480: disable "restore pages" popup, but not when we attach an existing browser as it crashes driver (from invalid argument: cannot parse capability: goog:chromeOptions, from invalid argument: unrecognized chrome option: prefs)
Map<String, Object> prefs = new HashMap<>();
prefs.put("profile.exit_type", "Normal");
options.setExperimentalOption("prefs", prefs);
}
options.setPageLoadStrategy(webDriverConfig.getPageLoadStrategy());
return options;
}
use of com.microsoft.edge.seleniumtools.EdgeOptions in project HYR-Tutorials by YadaGiriReddy.
the class TestBrowserMaximization method main.
public static void main(String[] args) throws Exception {
// Way 1 - Chrome
// WebDriverManager.chromedriver().setup();
// WebDriver driver = new ChromeDriver();
// driver.manage().window().maximize();
// driver.get("https://www.google.com/");
// Way 1 - Firefox
// WebDriverManager.firefoxdriver().setup();
// WebDriver driver = new FirefoxDriver();
// driver.manage().window().maximize();
// driver.get("https://www.google.com/");
// Way 1 - Edge
// WebDriverManager.edgedriver().setup();
// WebDriver driver = new EdgeDriver();
// driver.manage().window().maximize();
// driver.get("https://www.google.com/");
// Way 2 - Chrome
// WebDriverManager.chromedriver().setup();
// ChromeOptions options = new ChromeOptions();
// options.addArguments("start-maximized");
// WebDriver driver = new ChromeDriver(options);
// driver.get("https://www.google.com/");
// Way 2 - Edge
WebDriverManager.edgedriver().setup();
EdgeOptions options = new EdgeOptions();
options.addArguments("start-maximized");
WebDriver driver = new EdgeDriver(options);
driver.get("https://www.google.com/");
}
use of com.microsoft.edge.seleniumtools.EdgeOptions in project seleniumRobot by bhecquet.
the class TestEdgeCapabilityFactory method testCreateDefaultEdgeCapabilitiesAttach.
/**
* Check we set debugger address
*/
@Test(groups = { "ut" })
public void testCreateDefaultEdgeCapabilitiesAttach() {
when(config.getAttachExistingDriverPort()).thenReturn(10);
MutableCapabilities capa = new EdgeCapabilitiesFactory(config).createCapabilities();
Assert.assertEquals(((Map<?, ?>) (((EdgeOptions) capa).asMap().get(EdgeOptions.CAPABILITY))).get("args").toString(), "[--disable-translate, --disable-web-security, --no-sandbox, --disable-site-isolation-trials, --disable-features=IsolateOrigins,site-per-process]");
Assert.assertEquals(capa.getCapability(CapabilityType.BROWSER_NAME), "MicrosoftEdge");
// no preference set when attaching to existing browser
Assert.assertNull(((Map<?, ?>) (((EdgeOptions) capa).asMap().get(EdgeOptions.CAPABILITY))).get("prefs"));
Assert.assertEquals(((Map<?, ?>) (((EdgeOptions) capa).asMap().get(EdgeOptions.CAPABILITY))).get("debuggerAddress"), "127.0.0.1:10");
}
Aggregations