Search in sources :

Example 6 with DriverExceptions

use of com.seleniumtests.customexception.DriverExceptions in project seleniumRobot by bhecquet.

the class StubTestClass method testWithExceptionAndMaxRetryIncreased.

/**
 * Increase max retry
 */
@Test(groups = "stub")
public void testWithExceptionAndMaxRetryIncreased() {
    count++;
    TestStep step1 = new TestStep("step 1", Reporter.getCurrentTestResult(), new ArrayList<>(), maskPassword);
    step1.addAction(new TestAction(String.format("played %d times", count), false, new ArrayList<>()));
    step1.addAction(new TestAction("click button", false, new ArrayList<>()));
    TestStepManager.logTestStep(step1);
    try {
        throw new DriverExceptions("some exception");
    } finally {
        if (count < 3) {
            increaseMaxRetry();
        }
    }
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) DriverExceptions(com.seleniumtests.customexception.DriverExceptions) ArrayList(java.util.ArrayList) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test)

Example 7 with DriverExceptions

use of com.seleniumtests.customexception.DriverExceptions in project seleniumRobot by bhecquet.

the class StubTestClass method testWithExceptionAndDataProvider.

@Test(groups = "stub", dataProvider = "data")
public void testWithExceptionAndDataProvider(String data) {
    count++;
    TestStep step1 = new TestStep("step 1", Reporter.getCurrentTestResult(), new ArrayList<>(), maskPassword);
    step1.addAction(new TestAction(String.format("played %d times", count), false, new ArrayList<>()));
    step1.addAction(new TestAction("click button", false, new ArrayList<>()));
    TestStepManager.logTestStep(step1);
    throw new DriverExceptions("some exception");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) DriverExceptions(com.seleniumtests.customexception.DriverExceptions) ArrayList(java.util.ArrayList) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test)

Example 8 with DriverExceptions

use of com.seleniumtests.customexception.DriverExceptions in project seleniumRobot by bhecquet.

the class StubTestClassForEncoding method testWithException.

@Test(groups = "stub")
public void testWithException() {
    TestStep step1 = new TestStep("step 1", Reporter.getCurrentTestResult(), new ArrayList<>(), true);
    step1.addAction(new TestAction("click button", false, new ArrayList<>()));
    TestStepManager.logTestStep(step1);
    throw new DriverExceptions("& some exception \"with \" <strong><a href='http://someurl/link' style='background-color: red;'>HTML to encode</a></strong>");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) DriverExceptions(com.seleniumtests.customexception.DriverExceptions) ArrayList(java.util.ArrayList) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test)

Example 9 with DriverExceptions

use of com.seleniumtests.customexception.DriverExceptions in project seleniumRobot by bhecquet.

the class DriverExtractor method copyDriver.

public void copyDriver(String driverName) {
    InputStream driver = Thread.currentThread().getContextClassLoader().getResourceAsStream(String.format("drivers/%s/%s%s", os, driverName, OSUtilityFactory.getInstance().getProgramExtension()));
    if (driver == null) {
        throw new DriverExceptions(String.format("Driver %s does not exist in resources", driverName));
    }
    Path driverPath = getDriverPath(driverName);
    driverPath.toFile().getParentFile().mkdirs();
    try {
        Files.copy(driver, driverPath, StandardCopyOption.REPLACE_EXISTING);
        if (!driverPath.toFile().setExecutable(true)) {
            logger.warn(String.format("Driver %s could not be set to executable", driverPath));
        }
        logger.info(String.format("Driver %s copied to %s", driverName, driverPath));
    } catch (IOException e) {
        logger.info(String.format("Driver not copied: %s - it may be in use", driverName));
    }
}
Also used : Path(java.nio.file.Path) InputStream(java.io.InputStream) DriverExceptions(com.seleniumtests.customexception.DriverExceptions) IOException(java.io.IOException)

Example 10 with DriverExceptions

use of com.seleniumtests.customexception.DriverExceptions in project seleniumRobot by bhecquet.

the class StubTestClass method testWithException2.

/**
 * An other test that throws exception
 */
@Test(groups = "stub", dependsOnMethods = "testAndSubActions")
public void testWithException2() {
    TestStep step1 = new TestStep("step 1", Reporter.getCurrentTestResult(), new ArrayList<>(), maskPassword);
    step1.addAction(new TestAction(String.format("played %d times", count), false, new ArrayList<>()));
    step1.addAction(new TestAction("click button", false, new ArrayList<>()));
    TestStepManager.logTestStep(step1);
    throw new DriverExceptions("some exception");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) DriverExceptions(com.seleniumtests.customexception.DriverExceptions) ArrayList(java.util.ArrayList) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test)

Aggregations

DriverExceptions (com.seleniumtests.customexception.DriverExceptions)13 TestAction (com.seleniumtests.reporter.logger.TestAction)8 TestStep (com.seleniumtests.reporter.logger.TestStep)8 ArrayList (java.util.ArrayList)8 Test (org.testng.annotations.Test)8 MalformedURLException (java.net.MalformedURLException)3 URL (java.net.URL)3 MutableCapabilities (org.openqa.selenium.MutableCapabilities)3 WebElement (org.openqa.selenium.WebElement)3 AndroidDriver (io.appium.java_client.android.AndroidDriver)2 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)2 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Path (java.nio.file.Path)1 RemoteWebElement (org.openqa.selenium.remote.RemoteWebElement)1