Search in sources :

Example 1 with IECapabilitiesFactory

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

the class TestIECapabilityFactory method testCreateIECapabilitiesOverrideDriverPathLocal.

@Test(groups = { "ut" })
public void testCreateIECapabilitiesOverrideDriverPathLocal() {
    try {
        PowerMockito.mockStatic(Advapi32Util.class);
        PowerMockito.when(Advapi32Util.registryGetValue(any(HKEY.class), anyString(), anyString())).thenReturn("1");
        Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);
        Mockito.when(config.getIeDriverPath()).thenReturn("/opt/ie/driver/ie");
        new IECapabilitiesFactory(config).createCapabilities();
        Assert.assertEquals(System.getProperty(InternetExplorerDriverService.IE_DRIVER_EXE_PROPERTY).replace(File.separator, "/"), "/opt/ie/driver/ie");
    } finally {
        System.clearProperty(InternetExplorerDriverService.IE_DRIVER_EXE_PROPERTY);
    }
}
Also used : HKEY(com.sun.jna.platform.win32.WinReg.HKEY) IECapabilitiesFactory(com.seleniumtests.browserfactory.IECapabilitiesFactory) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 2 with IECapabilitiesFactory

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

the class TestIECapabilityFactory method testCreateDefaultEdgeIEModeCapabilitiesGrid.

/**
 * Edge IE mode in grid
 * Check ie.edgepath and ie.edgechromium capabilities are not set
 */
@Test(groups = { "ut" })
public void testCreateDefaultEdgeIEModeCapabilitiesGrid() {
    Mockito.when(config.getIeMode()).thenReturn(true);
    Mockito.when(config.getMode()).thenReturn(DriverMode.GRID);
    Mockito.when(config.getInitialUrl()).thenReturn("http://mysite");
    Map<BrowserType, List<BrowserInfo>> browserInfos = new HashMap<>();
    browserInfos.put(BrowserType.INTERNET_EXPLORER, Arrays.asList(new BrowserInfo(BrowserType.INTERNET_EXPLORER, "11", "", false)));
    browserInfos.put(BrowserType.EDGE, Arrays.asList(new BrowserInfo(BrowserType.EDGE, "97.0", "", false)));
    PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion(false)).thenReturn(browserInfos);
    MutableCapabilities capa = new IECapabilitiesFactory(config).createCapabilities();
    Assert.assertEquals(capa.getCapability(CapabilityType.BROWSER_NAME), "internet explorer");
    Assert.assertTrue((Boolean) capa.getCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING));
    Assert.assertTrue((Boolean) capa.getCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS));
    Assert.assertTrue((Boolean) capa.getCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION));
    Assert.assertEquals((String) capa.getCapability(InternetExplorerDriver.INITIAL_BROWSER_URL), "http://mysite");
    Assert.assertNull((Boolean) capa.getCapability("ie.edgechromium"));
    Assert.assertNull((String) capa.getCapability("ie.edgepath"), "");
    Assert.assertNull(((Map<String, Object>) capa.getCapability(IECapabilitiesFactory.SE_IE_OPTIONS)).get("ie.edgepath"));
    Assert.assertNull(((Map<String, Object>) capa.getCapability(IECapabilitiesFactory.SE_IE_OPTIONS)).get("ie.edgechromium"));
}
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) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) IECapabilitiesFactory(com.seleniumtests.browserfactory.IECapabilitiesFactory) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 3 with IECapabilitiesFactory

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

the class TestIECapabilityFactory method testCreateDefaultCapabilitiesWithNodeTagsInGridMode.

/**
 * Check default behaviour when node tags are defined in grid mode
 * tags are transferred to driver
 */
@Test(groups = { "ut" })
public void testCreateDefaultCapabilitiesWithNodeTagsInGridMode() {
    Mockito.when(config.isEnableJavascript()).thenReturn(true);
    Mockito.when(config.getProxy()).thenReturn(proxyConfig);
    Mockito.when(config.getNodeTags()).thenReturn(Arrays.asList("foo", "bar"));
    Mockito.when(config.getMode()).thenReturn(DriverMode.GRID);
    MutableCapabilities capa = new IECapabilitiesFactory(config).createCapabilities();
    Assert.assertEquals(capa.getCapability(SeleniumRobotCapabilityType.NODE_TAGS), Arrays.asList("foo", "bar"));
}
Also used : MutableCapabilities(org.openqa.selenium.MutableCapabilities) IECapabilitiesFactory(com.seleniumtests.browserfactory.IECapabilitiesFactory) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 4 with IECapabilitiesFactory

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

the class TestIECapabilityFactory method testCreateIECapabilitiesStandardDriverPathGrid.

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

Example 5 with IECapabilitiesFactory

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

the class TestIECapabilityFactory method testCreateDefaultCapabilitiesWithNodeTagsInLocalMode.

/**
 * Check default behaviour when node tags are defined in local mode
 * tags are not transferred to driver
 */
@Test(groups = { "ut" })
public void testCreateDefaultCapabilitiesWithNodeTagsInLocalMode() {
    Mockito.when(config.getNodeTags()).thenReturn(Arrays.asList("foo", "bar"));
    Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);
    MutableCapabilities capa = new IECapabilitiesFactory(config).createCapabilities();
    Assert.assertFalse(capa.is(SeleniumRobotCapabilityType.NODE_TAGS));
}
Also used : MutableCapabilities(org.openqa.selenium.MutableCapabilities) IECapabilitiesFactory(com.seleniumtests.browserfactory.IECapabilitiesFactory) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Aggregations

MockitoTest (com.seleniumtests.MockitoTest)13 IECapabilitiesFactory (com.seleniumtests.browserfactory.IECapabilitiesFactory)13 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)13 Test (org.testng.annotations.Test)13 MutableCapabilities (org.openqa.selenium.MutableCapabilities)10 BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)2 BrowserType (com.seleniumtests.driver.BrowserType)2 HKEY (com.sun.jna.platform.win32.WinReg.HKEY)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 Map (java.util.Map)1