Search in sources :

Example 1 with EdgeOptions

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"));
}
Also used : EdgeOptions(com.microsoft.edge.seleniumtools.EdgeOptions) MutableCapabilities(org.openqa.selenium.MutableCapabilities) ArrayList(java.util.ArrayList) List(java.util.List) EdgeCapabilitiesFactory(com.seleniumtests.browserfactory.EdgeCapabilitiesFactory) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 2 with EdgeOptions

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="));
}
Also used : EdgeOptions(com.microsoft.edge.seleniumtools.EdgeOptions) MutableCapabilities(org.openqa.selenium.MutableCapabilities) HashMap(java.util.HashMap) Map(java.util.Map) EdgeCapabilitiesFactory(com.seleniumtests.browserfactory.EdgeCapabilitiesFactory) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 3 with EdgeOptions

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;
}
Also used : EdgeOptions(com.microsoft.edge.seleniumtools.EdgeOptions) HashMap(java.util.HashMap)

Example 4 with EdgeOptions

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/");
}
Also used : WebDriver(org.openqa.selenium.WebDriver) EdgeOptions(com.microsoft.edge.seleniumtools.EdgeOptions) EdgeDriver(com.microsoft.edge.seleniumtools.EdgeDriver)

Example 5 with EdgeOptions

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");
}
Also used : EdgeOptions(com.microsoft.edge.seleniumtools.EdgeOptions) MutableCapabilities(org.openqa.selenium.MutableCapabilities) HashMap(java.util.HashMap) Map(java.util.Map) EdgeCapabilitiesFactory(com.seleniumtests.browserfactory.EdgeCapabilitiesFactory) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Aggregations

EdgeOptions (com.microsoft.edge.seleniumtools.EdgeOptions)7 MockitoTest (com.seleniumtests.MockitoTest)5 EdgeCapabilitiesFactory (com.seleniumtests.browserfactory.EdgeCapabilitiesFactory)5 MutableCapabilities (org.openqa.selenium.MutableCapabilities)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 Test (org.testng.annotations.Test)5 HashMap (java.util.HashMap)4 Map (java.util.Map)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 EdgeDriver (com.microsoft.edge.seleniumtools.EdgeDriver)1 WebDriver (org.openqa.selenium.WebDriver)1