Search in sources :

Example 46 with BrowserInfo

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

the class TestBrowserInfo method testGetDefaultEdgeMacProfile.

@Test(groups = { "ut" })
public void testGetDefaultEdgeMacProfile() throws Exception {
    PowerMockito.mockStatic(OSUtility.class);
    when(OSUtility.getCurrentPlatorm()).thenReturn(Platform.MAC);
    BrowserInfo bi = new BrowserInfo(BrowserType.EDGE, "90.0", null);
    Assert.assertTrue(bi.getDefaultProfilePath().matches("/Users/.*?/Library/Application Support/Microsoft/Edge"));
}
Also used : BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 47 with BrowserInfo

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

the class TestChromeCapabilityFactory method testNonBetaVersionBrowserAbsent.

/**
 * If beta is not requested, and non beta browser not installed, return null
 */
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class, expectedExceptionsMessageRegExp = "Browser CHROME  is not available")
public void testNonBetaVersionBrowserAbsent() {
    when(config.getMode()).thenReturn(DriverMode.LOCAL);
    Map<BrowserType, List<BrowserInfo>> browserInfos = new HashMap<>();
    browserInfos.put(BrowserType.CHROME, Arrays.asList(new BrowserInfo(BrowserType.CHROME, "97.0", "", false, true)));
    PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion(false)).thenReturn(browserInfos);
    ChromeCapabilitiesFactory capaFactory = new ChromeCapabilitiesFactory(config);
    capaFactory.createCapabilities();
}
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 48 with BrowserInfo

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

the class TestChromeCapabilityFactory method testBetaVersionBrowserAbsent.

/**
 * If beta is not requested, and non beta browser not installed, return null
 */
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class, expectedExceptionsMessageRegExp = "Browser CHROME beta is not available")
public void testBetaVersionBrowserAbsent() {
    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)));
    PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion(true)).thenReturn(browserInfos);
    when(config.getBetaBrowser()).thenReturn(true);
    ChromeCapabilitiesFactory capaFactory = new ChromeCapabilitiesFactory(config);
    capaFactory.createCapabilities();
}
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 49 with BrowserInfo

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

the class TestBrowserInfo method testChromeVersionHigherThanDriverVersion.

/**
 * Check that no error is raised if browser version is higher than available version
 * an error message should be displayed
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testChromeVersionHigherThanDriverVersion() throws Exception {
    List<String> driverList = Arrays.asList("chromedriver_2.28_chrome-55-57_android_7.0", "chromedriver_2.29_chrome-56-58_android_7.0", "chromedriver_2.31_chrome-58-60");
    BrowserInfo bInfo = PowerMockito.spy(new BrowserInfo(BrowserType.CHROME, "70.0", null));
    PowerMockito.when(bInfo, "getDriverFiles").thenReturn(driverList);
    PowerMockito.doNothing().when(bInfo, "checkResourceExists");
    Assert.assertEquals(bInfo.getDriverFileName(), "chromedriver_2.31_chrome-58-60");
}
Also used : BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 50 with BrowserInfo

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

the class TestBrowserInfo method testGetFilesFromList.

/**
 * Check we take the highest driver version matching this chrome version
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testGetFilesFromList() throws Exception {
    List<String> driverList = Arrays.asList("chromedriver_2.28_chrome-55-57_android_7.0.exe", "chromedriver_2.29_chrome-56-58_android_7.0.exe", "chromedriver_2.31_chrome-58-60.exe");
    BrowserInfo bInfo = PowerMockito.spy(new BrowserInfo(BrowserType.CHROME, "58.0", null));
    BrowserInfo.setDriverList(driverList);
    PowerMockito.doNothing().when(bInfo, "checkResourceExists");
    Assert.assertEquals(bInfo.getDriverFileName(), "chromedriver_2.31_chrome-58-60");
}
Also used : BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

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