Search in sources :

Example 11 with BrowserType

use of com.seleniumtests.driver.BrowserType in project seleniumRobot by bhecquet.

the class TestEdgeCapabilityFactory method testBetaVersionBrowserAbsent.

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

use of com.seleniumtests.driver.BrowserType in project seleniumRobot by bhecquet.

the class TestMarionetteCapabilitiesFactory method testCreateMarionetteCapabilitiesOverrideBinPath.

@Test(groups = { "ut" })
public void testCreateMarionetteCapabilitiesOverrideBinPath() {
    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, "57.0", "", false), new BrowserInfo(BrowserType.FIREFOX, "58.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 13 with BrowserType

use of com.seleniumtests.driver.BrowserType 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 14 with BrowserType

use of com.seleniumtests.driver.BrowserType in project seleniumRobot by bhecquet.

the class TestPageObject method testPageObjectForExternalDriver.

/**
 * issue #324: check handles are not null. We cannot directly reproduce problem because we should have a test site which creates a second window when opened
 * @throws Exception
 */
@Test(groups = { "it", "pageobject" })
public void testPageObjectForExternalDriver() throws Exception {
    try {
        SeleniumTestsContextManager.getThreadContext().setTestType(TestType.WEB);
        Map<BrowserType, List<BrowserInfo>> browsers = OSUtility.getInstalledBrowsersWithVersion();
        String path = browsers.get(BrowserType.CHROME).get(0).getPath();
        int port = GenericDriverTest.findFreePort();
        // create chrome browser with the right option
        OSCommand.executeCommand(new String[] { path, "--remote-debugging-port=" + port, "about:blank" });
        DriverTestPage secondPage = new DriverTestPage(BrowserType.CHROME, port);
        Assert.assertNotNull(secondPage.getCurrentHandles());
    } finally {
        // switch back to main driver to avoid annoying other tests
        testPage.switchToDriver("main");
    }
}
Also used : DriverTestPage(com.seleniumtests.it.driver.support.pages.DriverTestPage) BrowserType(com.seleniumtests.driver.BrowserType) List(java.util.List) GenericDriverTest(com.seleniumtests.GenericDriverTest) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 15 with BrowserType

use of com.seleniumtests.driver.BrowserType in project seleniumRobot by bhecquet.

the class TestLinuxOsUtility method testChromeStandardInstallation.

@Test(groups = { "ut" })
public void testChromeStandardInstallation() {
    PowerMockito.mockStatic(OSCommand.class);
    PowerMockito.mockStatic(Paths.class);
    when(Paths.get("/usr/local/bin/google-chrome")).thenReturn(path);
    when(path.toFile()).thenReturn(browserFile);
    when(browserFile.exists()).thenReturn(true);
    when(OSCommand.executeCommandAndWait("which google-chrome")).thenReturn("/usr/local/bin/google-chrome");
    when(OSCommand.executeCommandAndWait(new String[] { "google-chrome", "--version" })).thenReturn("Google Chrome 57.0.2987.110");
    when(OSCommand.executeCommandAndWait("which firefox")).thenReturn("/usr/bin/which: no firefox in (/usr/local/sbin)");
    when(OSCommand.executeCommandAndWait("which iceweasel")).thenReturn("/usr/bin/which: no iceweasel in (/usr/local/sbin)");
    when(OSCommand.executeCommandAndWait("which chromium-browser")).thenReturn("/usr/bin/which: no chromium-browser in (/usr/local/sbin)");
    Map<BrowserType, List<BrowserInfo>> browsers = new OSUtilityUnix().discoverInstalledBrowsersWithVersion();
    assertTrue(browsers.containsKey(BrowserType.CHROME));
}
Also used : OSUtilityUnix(com.seleniumtests.util.osutility.OSUtilityUnix) BrowserType(com.seleniumtests.driver.BrowserType) List(java.util.List) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Aggregations

BrowserType (com.seleniumtests.driver.BrowserType)32 List (java.util.List)28 Test (org.testng.annotations.Test)26 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)25 MockitoTest (com.seleniumtests.MockitoTest)22 ArrayList (java.util.ArrayList)20 BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)18 HashMap (java.util.HashMap)14 MutableCapabilities (org.openqa.selenium.MutableCapabilities)6 ChromeCapabilitiesFactory (com.seleniumtests.browserfactory.ChromeCapabilitiesFactory)5 EdgeCapabilitiesFactory (com.seleniumtests.browserfactory.EdgeCapabilitiesFactory)5 GenericDriverTest (com.seleniumtests.GenericDriverTest)4 OSUtilityUnix (com.seleniumtests.util.osutility.OSUtilityUnix)4 Path (java.nio.file.Path)4 CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)3 ReporterTest (com.seleniumtests.it.reporter.ReporterTest)3 TextFieldElement (com.seleniumtests.uipage.htmlelements.TextFieldElement)3 EnumMap (java.util.EnumMap)3 Map (java.util.Map)3 WebDriver (org.openqa.selenium.WebDriver)3