Search in sources :

Example 1 with EdgeCapabilitiesFactory

use of com.seleniumtests.browserfactory.EdgeCapabilitiesFactory in project seleniumRobot by bhecquet.

the class TestEdgeCapabilityFactory method testCreateEdgeCapabilitiesOverrideBinPath.

/**
 * check the case where we have a beta browser. The last one is choosen
 */
@Test(groups = { "ut" })
public void testCreateEdgeCapabilitiesOverrideBinPath() {
    when(config.getMode()).thenReturn(DriverMode.LOCAL);
    // SeleniumTestsContext class adds a browserInfo when binary path is set
    Map<BrowserType, List<BrowserInfo>> updatedBrowserInfos = new HashMap<>();
    updatedBrowserInfos.put(BrowserType.EDGE, Arrays.asList(new BrowserInfo(BrowserType.EDGE, "92.0", "", false), new BrowserInfo(BrowserType.EDGE, "93.0", "/opt/edge/bin/edge", false)));
    PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion(false)).thenReturn(updatedBrowserInfos);
    MutableCapabilities capa = new EdgeCapabilitiesFactory(config).createCapabilities();
    Assert.assertEquals(((Map<?, ?>) (((EdgeOptions) capa).asMap().get(EdgeOptions.CAPABILITY))).get("binary").toString(), "/opt/edge/bin/edge");
}
Also used : BrowserType(com.seleniumtests.driver.BrowserType) HashMap(java.util.HashMap) BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) MutableCapabilities(org.openqa.selenium.MutableCapabilities) ArrayList(java.util.ArrayList) List(java.util.List) 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 2 with EdgeCapabilitiesFactory

use of com.seleniumtests.browserfactory.EdgeCapabilitiesFactory in project seleniumRobot by bhecquet.

the class TestEdgeCapabilityFactory method testCreateDefaultCapabilities.

/**
 * Check default behaviour
 */
@Test(groups = { "ut" })
public void testCreateDefaultCapabilities() {
    when(config.isEnableJavascript()).thenReturn(true);
    when(config.getProxy()).thenReturn(proxyConfig);
    when(config.getNodeTags()).thenReturn(new ArrayList<>());
    MutableCapabilities capa = new EdgeCapabilitiesFactory(config).createCapabilities();
    Assert.assertTrue(capa.is(CapabilityType.SUPPORTS_JAVASCRIPT));
    Assert.assertTrue(capa.is(CapabilityType.TAKES_SCREENSHOT));
    Assert.assertTrue(capa.is(CapabilityType.ACCEPT_SSL_CERTS));
    Assert.assertFalse(capa.is(SeleniumRobotCapabilityType.NODE_TAGS));
    Assert.assertEquals(capa.getVersion(), "");
    Assert.assertEquals(capa.getCapability(CapabilityType.PROXY), proxyConfig);
}
Also used : MutableCapabilities(org.openqa.selenium.MutableCapabilities) EdgeCapabilitiesFactory(com.seleniumtests.browserfactory.EdgeCapabilitiesFactory) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 3 with EdgeCapabilitiesFactory

use of com.seleniumtests.browserfactory.EdgeCapabilitiesFactory in project seleniumRobot by bhecquet.

the class TestEdgeCapabilityFactory method testCreateEdgeCapabilitiesOverrideUserAgent.

@Test(groups = { "ut" })
public void testCreateEdgeCapabilitiesOverrideUserAgent() {
    when(config.getUserAgentOverride()).thenReturn("EDGE 55");
    MutableCapabilities capa = new EdgeCapabilitiesFactory(config).createCapabilities();
    Assert.assertEquals(((Map<?, ?>) (((EdgeOptions) capa).asMap().get(EdgeOptions.CAPABILITY))).get("args").toString(), "[--user-agent=EDGE 55, --disable-translate, --disable-web-security, --no-sandbox, --disable-site-isolation-trials, --disable-features=IsolateOrigins,site-per-process]");
}
Also used : 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 4 with EdgeCapabilitiesFactory

use of com.seleniumtests.browserfactory.EdgeCapabilitiesFactory in project seleniumRobot by bhecquet.

the class TestEdgeCapabilityFactory method testCreateEdgeCapabilitiesStandardDriverPathGrid.

@Test(groups = { "ut" })
public void testCreateEdgeCapabilitiesStandardDriverPathGrid() {
    when(config.getMode()).thenReturn(DriverMode.GRID);
    new EdgeCapabilitiesFactory(config).createCapabilities();
    Assert.assertNull(System.getProperty(EdgeDriverService.EDGE_DRIVER_EXE_PROPERTY));
}
Also used : EdgeCapabilitiesFactory(com.seleniumtests.browserfactory.EdgeCapabilitiesFactory) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 5 with EdgeCapabilitiesFactory

use of com.seleniumtests.browserfactory.EdgeCapabilitiesFactory in project seleniumRobot by bhecquet.

the class TestEdgeCapabilityFactory method testNonBetaVersionBrowserAbsent.

/**
 * If beta is not requested, and non beta browser not installed, return null
 */
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class, expectedExceptionsMessageRegExp = "Browser EDGE  is not available")
public void testNonBetaVersionBrowserAbsent() {
    when(config.getMode()).thenReturn(DriverMode.LOCAL);
    Map<BrowserType, List<BrowserInfo>> browserInfos = new HashMap<>();
    browserInfos.put(BrowserType.EDGE, Arrays.asList(new BrowserInfo(BrowserType.EDGE, "102.0", "", false, true)));
    PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion(false)).thenReturn(browserInfos);
    EdgeCapabilitiesFactory capaFactory = new EdgeCapabilitiesFactory(config);
    capaFactory.createCapabilities();
}
Also used : BrowserType(com.seleniumtests.driver.BrowserType) HashMap(java.util.HashMap) BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) 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)

Aggregations

MockitoTest (com.seleniumtests.MockitoTest)27 EdgeCapabilitiesFactory (com.seleniumtests.browserfactory.EdgeCapabilitiesFactory)27 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)27 Test (org.testng.annotations.Test)27 MutableCapabilities (org.openqa.selenium.MutableCapabilities)19 HashMap (java.util.HashMap)14 Map (java.util.Map)10 ArrayList (java.util.ArrayList)7 List (java.util.List)7 EdgeOptions (com.microsoft.edge.seleniumtools.EdgeOptions)5 BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)5 BrowserType (com.seleniumtests.driver.BrowserType)5