Search in sources :

Example 21 with BrowserInfo

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

the class TestBrowserInfo method testAndroidVersionNoDriver.

/**
 * Error raised if no driver file exists
 * @throws Exception
 */
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testAndroidVersionNoDriver() throws Exception {
    List<String> driverList = Arrays.asList("chromedriver_2.31_chrome-58-60");
    BrowserInfo bInfo = PowerMockito.spy(new BrowserInfo(BrowserType.BROWSER, "5.0", null));
    PowerMockito.when(bInfo, "getDriverFiles").thenReturn(driverList);
    PowerMockito.doNothing().when(bInfo, "checkResourceExists");
    bInfo.getDriverFileName();
}
Also used : BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 22 with BrowserInfo

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

the class TestBrowserInfo method testAndroidVersionNoMatch.

/**
 * Error raised if no version matches
 * @throws Exception
 */
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testAndroidVersionNoMatch() throws Exception {
    List<String> driverList = Arrays.asList("chromedriver_2.20_chrome-55-57_android-6.0", "chromedriver_2.29_chrome-56-58_android-7.0", "chromedriver_2.31_chrome-58-60");
    BrowserInfo bInfo = PowerMockito.spy(new BrowserInfo(BrowserType.BROWSER, "5.0", null));
    PowerMockito.when(bInfo, "getDriverFiles").thenReturn(driverList);
    PowerMockito.doNothing().when(bInfo, "checkResourceExists");
    bInfo.getDriverFileName();
}
Also used : BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 23 with BrowserInfo

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

the class TestBrowserInfo method testGetInfoFromNonExistentVersion.

@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testGetInfoFromNonExistentVersion() {
    BrowserInfo bi1 = new BrowserInfo(BrowserType.CHROME, "48.0", null);
    BrowserInfo bi2 = new BrowserInfo(BrowserType.CHROME, "58.0", null);
    BrowserInfo.getInfoFromVersion("57.0", Arrays.asList(bi1, bi2));
}
Also used : BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 24 with BrowserInfo

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

the class TestChromeCapabilityFactory method testCreateChromeCapabilitiesOverrideBinPath.

/**
 */
@Test(groups = { "ut" })
public void testCreateChromeCapabilitiesOverrideBinPath() {
    when(config.getMode()).thenReturn(DriverMode.LOCAL);
    when(config.getChromeBinPath()).thenReturn("/opt/chrome/bin/chrome");
    // SeleniumTestsContext class adds a browserInfo when binary path is set
    Map<BrowserType, List<BrowserInfo>> updatedBrowserInfos = new HashMap<>();
    updatedBrowserInfos.put(BrowserType.CHROME, Arrays.asList(new BrowserInfo(BrowserType.CHROME, "102.0", "", false), new BrowserInfo(BrowserType.CHROME, "103.0", "/opt/chrome/bin/chrome", false)));
    PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion(false)).thenReturn(updatedBrowserInfos);
    MutableCapabilities capa = new ChromeCapabilitiesFactory(config).createCapabilities();
    Assert.assertEquals(((Map<?, ?>) (((ChromeOptions) capa).asMap().get(ChromeOptions.CAPABILITY))).get("binary").toString(), "/opt/chrome/bin/chrome");
}
Also used : ChromeCapabilitiesFactory(com.seleniumtests.browserfactory.ChromeCapabilitiesFactory) 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) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 25 with BrowserInfo

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

the class TestBrowserInfo method testBrowserInfoMarionetteFirefox.

@Test(groups = { "it" })
public void testBrowserInfoMarionetteFirefox() {
    BrowserInfo browserInfo = new BrowserInfo(BrowserType.FIREFOX, "48.0", "/some/path", false);
    browserInfo.getDriverFileName();
    Assert.assertTrue(browserInfo.isDriverFileSearched());
    Assert.assertEquals(browserInfo.getDriverFileName(), "geckodriver");
}
Also used : BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) GenericDriverTest(com.seleniumtests.GenericDriverTest) Test(org.testng.annotations.Test)

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