Search in sources :

Example 56 with BrowserInfo

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

the class TestBrowserInfo method testGetDefaultChromeLinuxProfile.

@Test(groups = { "ut" })
public void testGetDefaultChromeLinuxProfile() throws Exception {
    PowerMockito.mockStatic(OSUtility.class);
    when(OSUtility.getCurrentPlatorm()).thenReturn(Platform.LINUX);
    BrowserInfo bi = new BrowserInfo(BrowserType.CHROME, "58.0", null);
    Assert.assertTrue(bi.getDefaultProfilePath().matches("/home/.*?/.config/google-chrome/default"));
}
Also used : BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 57 with BrowserInfo

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

the class TestBrowserInfo method testGetDriverFilesWithInstalledArtifact.

/**
 * Check that we get the driver list if driver artifact is installed for the right OS
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testGetDriverFilesWithInstalledArtifact() throws Exception {
    PowerMockito.mockStatic(OSUtility.class);
    when(OSUtility.getCurrentPlatorm()).thenReturn(Platform.WINDOWS);
    String[] driversFiles = new String[] { "windows/chromedriver_2.20_chrome-55-57_android-6.0.exe", "windows/chromedriver_2.29_chrome-56-58_android-7.0.exe", "windows/chromedriver_2.31_chrome-58-60.exe" };
    BrowserInfo bInfo = PowerMockito.spy(new BrowserInfo(BrowserType.CHROME, "55.0", null));
    PowerMockito.when(bInfo, "getDriverListFromJarResources", "driver-list-windows.txt").thenReturn(driversFiles);
    Assert.assertEquals(bInfo.getDriverFiles().size(), 3);
}
Also used : BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 58 with BrowserInfo

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

the class TestBrowserInfo method testGetDefaultFirefoxLinuxProfile.

@Test(groups = { "ut" })
public void testGetDefaultFirefoxLinuxProfile() throws Exception {
    PowerMockito.mockStatic(Files.class);
    PowerMockito.mockStatic(OSUtility.class);
    when(OSUtility.getCurrentPlatorm()).thenReturn(Platform.LINUX);
    when(Files.list(any(Path.class))).thenReturn(streamPaths);
    when(streamPaths.filter(any(Predicate.class))).thenReturn(streamPaths);
    when(streamPaths.collect(any())).thenReturn(Arrays.asList(Paths.get("/home/user/.mozilla/firefox")));
    BrowserInfo bi = new BrowserInfo(BrowserType.FIREFOX, "58.0", null);
    Assert.assertEquals(bi.getDefaultProfilePath().replace("\\", "/"), "/home/user/.mozilla/firefox");
}
Also used : Path(java.nio.file.Path) BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) Predicate(java.util.function.Predicate) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 59 with BrowserInfo

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

the class TestBrowserInfo method testChromeVersionBadPattern.

/**
 * Error should be raised when file pattern is not correct
 * @throws Exception
 */
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testChromeVersionBadPattern() throws Exception {
    List<String> driverList = Arrays.asList("chromedriver_2.20_chrome-55.0-57.0");
    BrowserInfo bInfo = PowerMockito.spy(new BrowserInfo(BrowserType.CHROME, "55.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 60 with BrowserInfo

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

the class TestChromeCapabilityFactory 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.CHROME, Arrays.asList(new BrowserInfo(BrowserType.CHROME, "96.0", "", false, false), new BrowserInfo(BrowserType.CHROME, "97.0", "", false, true)));
    PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion(true)).thenReturn(browserInfos);
    when(config.getBetaBrowser()).thenReturn(true);
    ChromeCapabilitiesFactory capaFactory = new ChromeCapabilitiesFactory(config);
    capaFactory.createCapabilities();
    Assert.assertTrue(capaFactory.getSelectedBrowserInfo().getBeta());
    Assert.assertEquals(capaFactory.getSelectedBrowserInfo().getVersion(), "97.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)

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