Search in sources :

Example 21 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project selenified by Coveros.

the class TestSetupTest method setupBrowserCapabilityInternetExplorerTest.

@Test
public void setupBrowserCapabilityInternetExplorerTest() throws InvalidBrowserException {
    TestSetup setup = new TestSetup();
    setup.setupBrowserCapability(Browser.INTERNETEXPLORER);
    DesiredCapabilities capability = setup.getDesiredCapabilities();
    Assert.assertEquals(capability.getBrowserName(), "internet explorer");
    Assert.assertEquals(capability.getCapability(CapabilityType.BROWSER_NAME), "internet explorer");
}
Also used : TestSetup(com.coveros.selenified.utilities.TestSetup) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) Test(org.testng.annotations.Test)

Example 22 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project selenified by Coveros.

the class TestSetupTest method setupBrowserCapabilityIphoneTest.

@Test
public void setupBrowserCapabilityIphoneTest() throws InvalidBrowserException {
    TestSetup setup = new TestSetup();
    setup.setupBrowserCapability(Browser.IPHONE);
    DesiredCapabilities capability = setup.getDesiredCapabilities();
    Assert.assertEquals(capability.getBrowserName(), "iPhone");
    Assert.assertEquals(capability.getCapability(CapabilityType.BROWSER_NAME), "iPhone");
}
Also used : TestSetup(com.coveros.selenified.utilities.TestSetup) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) Test(org.testng.annotations.Test)

Example 23 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project selenified by Coveros.

the class TestSetupTest method setupBrowserDetailsBrowserNameTest.

@Test
public void setupBrowserDetailsBrowserNameTest() {
    TestSetup setup = new TestSetup();
    setup.setupBrowserDetails(null);
    DesiredCapabilities capability = setup.getDesiredCapabilities();
    Assert.assertFalse(capability.is(CapabilityType.BROWSER_NAME));
    Assert.assertNull(capability.getCapability(CapabilityType.BROWSER_NAME));
    setup.setupBrowserDetails(new HashMap<>());
    capability = setup.getDesiredCapabilities();
    Assert.assertFalse(capability.is(CapabilityType.BROWSER_NAME));
    Assert.assertNull(capability.getCapability(CapabilityType.BROWSER_NAME));
    Map<String, String> browserDetails = new HashMap<>();
    browserDetails.put("browserName", "CHROME");
    setup.setupBrowserDetails(browserDetails);
    capability = setup.getDesiredCapabilities();
    Assert.assertEquals(capability.getBrowserName(), "CHROME");
    Assert.assertEquals(capability.getCapability(CapabilityType.BROWSER_NAME), "CHROME");
}
Also used : TestSetup(com.coveros.selenified.utilities.TestSetup) HashMap(java.util.HashMap) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) Test(org.testng.annotations.Test)

Example 24 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project selenified by Coveros.

the class TestSetupTest method setupBrowserCapabilityFIREFOXTest.

@Test
public void setupBrowserCapabilityFIREFOXTest() throws InvalidBrowserException {
    TestSetup setup = new TestSetup();
    setup.setupBrowserCapability(Browser.FIREFOX);
    DesiredCapabilities capability = setup.getDesiredCapabilities();
    Assert.assertEquals(capability.getBrowserName(), "firefox");
    Assert.assertEquals(capability.getCapability(CapabilityType.BROWSER_NAME), "firefox");
}
Also used : TestSetup(com.coveros.selenified.utilities.TestSetup) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) Test(org.testng.annotations.Test)

Example 25 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project selenified by Coveros.

the class Selenified method startTest.

/**
 * Gathers all of the testing information, and setup up the logging. If a
 * selenium test is running, also sets up the webdriver object
 *
 * @param dataProvider - any objects that are being passed to the tests to loop
 *                     through as variables
 * @param method       - what is the method that is being run. the test name will be
 *                     extracted from this
 * @param test         - was the is context associated with this test suite. suite
 *                     information will be extracted from this
 * @param result       - where are the test results stored. browser information will
 *                     be kept here
 * @param selenium     - is this a selenium test. if so, the webdriver content will
 *                     be setup
 */
protected void startTest(Object[] dataProvider, Method method, ITestContext test, ITestResult result, DriverSetup selenium) {
    String testName = TestSetup.getTestName(method, dataProvider);
    String outputDir = test.getOutputDirectory();
    String extClass = method.getDeclaringClass().getName();
    String description = "";
    String group = "";
    Test annotation = method.getAnnotation(Test.class);
    // set description from annotation
    if (annotation.description() != null) {
        description = annotation.description();
    }
    // adding in the group if it exists
    if (annotation.groups() != null) {
        group = Arrays.toString(annotation.groups());
        group = group.substring(1, group.length() - 1);
    }
    while (test.getAttribute(testName + INVOCATION_COUNT) == null) {
        test.setAttribute(testName + INVOCATION_COUNT, 0);
    }
    int invocationCount = (int) test.getAttribute(testName + INVOCATION_COUNT);
    Browser myBrowser = browsers.get(invocationCount);
    if (!selenium.useBrowser()) {
        myBrowser = Browser.NONE;
    }
    DesiredCapabilities myCapability = capabilities.get(invocationCount);
    myCapability.setCapability("name", testName);
    this.capability.set(myCapability);
    OutputFile myFile = new OutputFile(outputDir, testName, myBrowser, getTestSite(extClass, test), test.getName(), group, getAuthor(extClass, test), getVersion(extClass, test), description);
    if (selenium.useBrowser()) {
        App app = null;
        try {
            app = new App(myBrowser, myCapability, myFile);
        } catch (InvalidBrowserException | MalformedURLException e) {
            log.error(e);
        }
        this.apps.set(app);
        this.calls.set(null);
        myFile.setApp(app);
        if (selenium.loadPage()) {
            loadInitialPage(app, getTestSite(extClass, test), myFile);
        }
    } else {
        HTTP http = new HTTP(getTestSite(extClass, test), servicesUser, servicesPass);
        Call call = new Call(http, myFile, extraHeaders);
        this.apps.set(null);
        this.calls.set(call);
    }
    this.browser.set(myBrowser);
    result.setAttribute(BROWSER_INPUT, myBrowser);
    this.files.set(myFile);
}
Also used : App(com.coveros.selenified.application.App) Call(com.coveros.selenified.services.Call) MalformedURLException(java.net.MalformedURLException) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) HTTP(com.coveros.selenified.services.HTTP) InvalidBrowserException(com.coveros.selenified.exceptions.InvalidBrowserException)

Aggregations

DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)178 File (java.io.File)55 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)40 URL (java.net.URL)34 HashMap (java.util.HashMap)34 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)30 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)29 Test (org.testng.annotations.Test)22 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)20 BeforeClass (org.junit.BeforeClass)19 TestSetup (com.coveros.selenified.utilities.TestSetup)17 FirefoxProfile (org.openqa.selenium.firefox.FirefoxProfile)17 PhantomJSDriver (org.openqa.selenium.phantomjs.PhantomJSDriver)16 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)14 MalformedURLException (java.net.MalformedURLException)13 Before (org.junit.Before)13 Test (org.junit.Test)13 InternetExplorerDriver (org.openqa.selenium.ie.InternetExplorerDriver)12 Actions (org.openqa.selenium.interactions.Actions)12 Dimension (org.openqa.selenium.Dimension)11