Search in sources :

Example 26 with FirefoxCapabilitiesFactory

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

the class TestFirefoxCapabilitiesFactory method testCreateFirefoxCapabilitiesOverrideUserAgent.

@Test(groups = { "ut" })
public void testCreateFirefoxCapabilitiesOverrideUserAgent() {
    Mockito.when(config.getUserAgentOverride()).thenReturn("FIREFOX 55");
    Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);
    MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();
    FirefoxProfile profile = (FirefoxProfile) capa.getCapability(FirefoxDriver.PROFILE);
    // check profile
    Assert.assertEquals(profile.getStringPreference("general.useragent.override", ""), "FIREFOX 55");
}
Also used : MutableCapabilities(org.openqa.selenium.MutableCapabilities) FirefoxCapabilitiesFactory(com.seleniumtests.browserfactory.FirefoxCapabilitiesFactory) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 27 with FirefoxCapabilitiesFactory

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

the class TestFirefoxCapabilitiesFactory method testCreateFirefoxCapabilitiesOverrideNtlmAuth.

@Test(groups = { "ut" })
public void testCreateFirefoxCapabilitiesOverrideNtlmAuth() {
    Mockito.when(config.getNtlmAuthTrustedUris()).thenReturn("uri://uri.ntlm");
    Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);
    MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();
    FirefoxProfile profile = (FirefoxProfile) capa.getCapability(FirefoxDriver.PROFILE);
    // check profile
    Assert.assertEquals(profile.getStringPreference("network.automatic-ntlm-auth.trusted-uris", ""), "uri://uri.ntlm");
}
Also used : MutableCapabilities(org.openqa.selenium.MutableCapabilities) FirefoxCapabilitiesFactory(com.seleniumtests.browserfactory.FirefoxCapabilitiesFactory) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 28 with FirefoxCapabilitiesFactory

use of com.seleniumtests.browserfactory.FirefoxCapabilitiesFactory 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 29 with FirefoxCapabilitiesFactory

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

the class TestFirefoxCapabilitiesFactory method testCreateDefaultCapabilitiesWithHeadless.

@Test(groups = { "ut" })
public void testCreateDefaultCapabilitiesWithHeadless() {
    Mockito.when(config.isEnableJavascript()).thenReturn(false);
    Mockito.when(config.isHeadlessBrowser()).thenReturn(true);
    MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();
    Assert.assertEquals(((Map<?, ?>) (((FirefoxOptions) capa).asMap().get(FirefoxOptions.FIREFOX_OPTIONS))).get("args").toString(), "[-headless, --window-size=1280,1024, --width=1280, --height=1024]");
}
Also used : MutableCapabilities(org.openqa.selenium.MutableCapabilities) FirefoxCapabilitiesFactory(com.seleniumtests.browserfactory.FirefoxCapabilitiesFactory) 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 30 with FirefoxCapabilitiesFactory

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

the class TestFirefoxCapabilitiesFactory method testCreateDefaultCapabilities.

/**
 * Check default behaviour
 */
@Test(groups = { "ut" })
public void testCreateDefaultCapabilities() {
    Mockito.when(config.isEnableJavascript()).thenReturn(true);
    Mockito.when(config.getProxy()).thenReturn(proxyConfig);
    Mockito.when(config.getNodeTags()).thenReturn(new ArrayList<>());
    MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();
    Assert.assertTrue(capa.is(CapabilityType.SUPPORTS_JAVASCRIPT));
    Assert.assertTrue(capa.is(CapabilityType.TAKES_SCREENSHOT));
    Assert.assertTrue(capa.is(CapabilityType.ACCEPT_SSL_CERTS));
    Assert.assertFalse(capa.is(SeleniumRobotCapabilityType.NODE_TAGS));
    Assert.assertEquals(capa.getVersion(), "");
    Assert.assertEquals(capa.getCapability(CapabilityType.PROXY), proxyConfig);
    Assert.assertEquals(((Map<?, ?>) (((FirefoxOptions) capa).asMap().get(FirefoxOptions.FIREFOX_OPTIONS))).get("args").toString(), "[]");
}
Also used : MutableCapabilities(org.openqa.selenium.MutableCapabilities) FirefoxCapabilitiesFactory(com.seleniumtests.browserfactory.FirefoxCapabilitiesFactory) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Aggregations

MockitoTest (com.seleniumtests.MockitoTest)38 FirefoxCapabilitiesFactory (com.seleniumtests.browserfactory.FirefoxCapabilitiesFactory)38 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)38 Test (org.testng.annotations.Test)38 MutableCapabilities (org.openqa.selenium.MutableCapabilities)35 FirefoxProfile (org.openqa.selenium.firefox.FirefoxProfile)10 HashMap (java.util.HashMap)4 BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)2 BrowserType (com.seleniumtests.driver.BrowserType)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2