Search in sources :

Example 61 with BrowserInfo

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

the class TestChromeCapabilityFactory method testNonBetaVersionBrowserChoosen.

/**
 * If beta is not requested, get the non beta version even if both are present
 */
@Test(groups = { "ut" })
public void testNonBetaVersionBrowserChoosen() {
    when(config.getMode()).thenReturn(DriverMode.LOCAL);
    Map<BrowserType, List<BrowserInfo>> browserInfos = new HashMap<>();
    browserInfos.put(BrowserType.CHROME, Arrays.asList(new BrowserInfo(BrowserType.CHROME, "96.0", "", false, false), new BrowserInfo(BrowserType.CHROME, "97.0", "", false, true)));
    PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion(false)).thenReturn(browserInfos);
    ChromeCapabilitiesFactory capaFactory = new ChromeCapabilitiesFactory(config);
    capaFactory.createCapabilities();
    Assert.assertFalse(capaFactory.getSelectedBrowserInfo().getBeta());
    Assert.assertEquals(capaFactory.getSelectedBrowserInfo().getVersion(), "96.0");
}
Also used : ChromeCapabilitiesFactory(com.seleniumtests.browserfactory.ChromeCapabilitiesFactory) BrowserType(com.seleniumtests.driver.BrowserType) HashMap(java.util.HashMap) BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 62 with BrowserInfo

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

the class TestEdgeCapabilityFactory method testNonBetaVersionBrowserChoosen.

/**
 * If beta is not requested, get the non beta version even if both are present
 */
@Test(groups = { "ut" })
public void testNonBetaVersionBrowserChoosen() {
    when(config.getMode()).thenReturn(DriverMode.LOCAL);
    Map<BrowserType, List<BrowserInfo>> browserInfos = new HashMap<>();
    browserInfos.put(BrowserType.EDGE, Arrays.asList(new BrowserInfo(BrowserType.EDGE, "101.0", "", false, false), new BrowserInfo(BrowserType.EDGE, "102.0", "", false, true)));
    PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion(false)).thenReturn(browserInfos);
    EdgeCapabilitiesFactory capaFactory = new EdgeCapabilitiesFactory(config);
    capaFactory.createCapabilities();
    Assert.assertFalse(capaFactory.getSelectedBrowserInfo().getBeta());
    Assert.assertEquals(capaFactory.getSelectedBrowserInfo().getVersion(), "101.0");
}
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)

Example 63 with BrowserInfo

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

the class TestEdgeCapabilityFactory method testBetaVersionBrowserChoosen.

/**
 * If beta is requested, get the beta version even if both are present
 */
@Test(groups = { "ut" })
public void testBetaVersionBrowserChoosen() {
    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, false), new BrowserInfo(BrowserType.EDGE, "103.0", "", false, true)));
    PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion(true)).thenReturn(browserInfos);
    when(config.getBetaBrowser()).thenReturn(true);
    EdgeCapabilitiesFactory capaFactory = new EdgeCapabilitiesFactory(config);
    capaFactory.createCapabilities();
    Assert.assertTrue(capaFactory.getSelectedBrowserInfo().getBeta());
    Assert.assertEquals(capaFactory.getSelectedBrowserInfo().getVersion(), "103.0");
}
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)

Example 64 with BrowserInfo

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

the class TestFirefoxCapabilitiesFactory method testCreateFirefoxCapabilitiesOverrideBinPath.

@Test(groups = { "ut" })
public void testCreateFirefoxCapabilitiesOverrideBinPath() {
    Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);
    Mockito.when(config.getFirefoxBinPath()).thenReturn("/opt/firefox/bin/firefox");
    // SeleniumTestsContext class adds a browserInfo when binary path is set
    Map<BrowserType, List<BrowserInfo>> updatedBrowserInfos = new HashMap<>();
    updatedBrowserInfos.put(BrowserType.FIREFOX, Arrays.asList(new BrowserInfo(BrowserType.FIREFOX, "47.0", "", false), new BrowserInfo(BrowserType.FIREFOX, "44.0", "/opt/firefox/bin/firefox", false)));
    PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion(false)).thenReturn(updatedBrowserInfos);
    MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();
    Assert.assertEquals(capa.getCapability(FirefoxDriver.BINARY), "/opt/firefox/bin/firefox");
}
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) FirefoxCapabilitiesFactory(com.seleniumtests.browserfactory.FirefoxCapabilitiesFactory) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 65 with BrowserInfo

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

the class TestIECapabilityFactory method testCreateDefaultEdgeIEModeCapabilities.

/**
 * Edge IE mode in local
 * Check ie.edgepath and ie.edgechromium capabilities are set
 */
@Test(groups = { "ut" })
public void testCreateDefaultEdgeIEModeCapabilities() {
    Mockito.when(config.getIeMode()).thenReturn(true);
    Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);
    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.assertTrue((Boolean) capa.getCapability("ie.edgechromium"));
    Assert.assertEquals((String) capa.getCapability("ie.edgepath"), "");
    Assert.assertEquals(((Map<String, Object>) capa.getCapability(IECapabilitiesFactory.SE_IE_OPTIONS)).get("ie.edgepath"), "");
    Assert.assertTrue((boolean) ((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) HashMap(java.util.HashMap) Map(java.util.Map) IECapabilitiesFactory(com.seleniumtests.browserfactory.IECapabilitiesFactory) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Aggregations

BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)71 Test (org.testng.annotations.Test)59 MockitoTest (com.seleniumtests.MockitoTest)53 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)53 ArrayList (java.util.ArrayList)23 List (java.util.List)19 BrowserType (com.seleniumtests.driver.BrowserType)18 HashMap (java.util.HashMap)14 MutableCapabilities (org.openqa.selenium.MutableCapabilities)9 GenericDriverTest (com.seleniumtests.GenericDriverTest)6 ChromeCapabilitiesFactory (com.seleniumtests.browserfactory.ChromeCapabilitiesFactory)5 EdgeCapabilitiesFactory (com.seleniumtests.browserfactory.EdgeCapabilitiesFactory)5 CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 EnumMap (java.util.EnumMap)3 Map (java.util.Map)3 SkipException (org.testng.SkipException)3 FirefoxCapabilitiesFactory (com.seleniumtests.browserfactory.FirefoxCapabilitiesFactory)2 IECapabilitiesFactory (com.seleniumtests.browserfactory.IECapabilitiesFactory)2 MobileDevice (com.seleniumtests.browserfactory.mobile.MobileDevice)2