Search in sources :

Example 16 with ConfigurationException

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

the class PerfectoCapabilitiesFactory method extractApiKey.

private String extractApiKey() {
    List<String> hubUrls = webDriverConfig.getHubUrl();
    if (hubUrls.isEmpty() || !hubUrls.get(0).contains(".perfectomobile.com/nexperience/perfectomobile/wd/hub")) {
        throw new ConfigurationException("Perfecto usage needs configuring 'webDriverGrid' parameter with the format 'https://<apikey>@<cloudName>.perfectomobile.com/nexperience/perfectomobile/wd/hub'");
    }
    String hubUrl = hubUrls.get(0);
    Matcher apiKeyMatcher = CLOUD_NAME_PATTERN.matcher(hubUrl);
    if (apiKeyMatcher.matches()) {
        return apiKeyMatcher.group(1);
    } else {
        throw new ConfigurationException("Api key no provided");
    }
}
Also used : ConfigurationException(com.seleniumtests.customexception.ConfigurationException) Matcher(java.util.regex.Matcher)

Example 17 with ConfigurationException

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

the class TestExistingAppiumLauncher method testAppiumStartup.

@Test(groups = { "it" }, enabled = false)
public void testAppiumStartup() {
    try {
        ExistingAppiumLauncher appium = new ExistingAppiumLauncher("http://localhost:4723/wd/hub/");
        appium.startAppium();
        appium.stopAppium();
    } catch (ConfigurationException e) {
        throw new SkipException("Test skipped, appium not correctly configured", e);
    }
}
Also used : ExistingAppiumLauncher(com.seleniumtests.browserfactory.mobile.ExistingAppiumLauncher) ConfigurationException(com.seleniumtests.customexception.ConfigurationException) SkipException(org.testng.SkipException) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 18 with ConfigurationException

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

the class TestFieldDetectorConnector method testFieldDetection.

@Test(groups = "it", enabled = false)
public void testFieldDetection() throws IOException {
    ImageFieldDetector imageFieldDetector;
    try {
        // imageFieldDetector = new ImageFieldDetector(createImageFromResource("tu/imageFieldDetection/browserCapture.png"), 0.75);
        imageFieldDetector = new ImageFieldDetector(new File("D:\\Dev\\seleniumRobot\\seleniumRobot-core\\core\\test-output\\testSendKeysWithLabelOnTheLeft\\screenshots\\f5972501f7e893bfa3aa0281e4f647e1.png"), 0.75);
    // imageFieldDetector = new ImageFieldDetector(createImageFromResource("ti/form_picture.png"), 0.75);
    } catch (ConfigurationException e) {
        throw new SkipException("no field detector server available");
    }
    List<Field> fields = imageFieldDetector.detectFields();
    Assert.assertTrue(fields.size() > 10);
}
Also used : Field(com.seleniumtests.connectors.selenium.fielddetector.Field) ConfigurationException(com.seleniumtests.customexception.ConfigurationException) ImageFieldDetector(com.seleniumtests.connectors.selenium.fielddetector.ImageFieldDetector) SkipException(org.testng.SkipException) File(java.io.File) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 19 with ConfigurationException

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

the class BrowserInfo method addAndroidDriverFile.

/**
 * Add the most suitable chrome driver for android driver version
 * @throws IOException
 */
private void addAndroidDriverFile() throws IOException {
    List<String> driverFiles = getDriverFiles();
    driverFiles = driverFiles.stream().filter(s -> s.contains("android-") && s.startsWith("chromedriver_")).map(s -> s.replace(".exe", "")).sorted().collect(Collectors.toList());
    if (driverFiles.isEmpty()) {
        throw new ConfigurationException("no chromedriver in resources");
    }
    Map<String, String> driverVersion = new HashMap<>();
    for (String fileName : driverFiles) {
        Matcher matcher = REG_ANDROID_VERSION.matcher(fileName);
        if (matcher.matches()) {
            driverVersion.put(matcher.group(1), fileName);
        } else {
            throw new ConfigurationException(String.format("Driver %s is excluded as it does not match the pattern 'chromedriver_<version>_android-<x.y>'", fileName));
        }
    }
    driverFileName = driverVersion.get(version);
    if (driverFileName == null) {
        throw new ConfigurationException(String.format("Chrome version %s does not have any associated driver, update seleniumRobot version", version));
    }
}
Also used : Win32Exception(com.sun.jna.platform.win32.Win32Exception) HashMap(java.util.HashMap) OSUtility(com.seleniumtests.util.osutility.OSUtility) ArrayList(java.util.ArrayList) Logger(org.apache.log4j.Logger) Matcher(java.util.regex.Matcher) SeleniumRobotLogger(com.seleniumtests.util.logging.SeleniumRobotLogger) ConfigurationException(com.seleniumtests.customexception.ConfigurationException) Map(java.util.Map) ManagementFactory(java.lang.management.ManagementFactory) WinReg(com.sun.jna.platform.win32.WinReg) Path(java.nio.file.Path) Files(java.nio.file.Files) Platform(org.openqa.selenium.Platform) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) BrowserType(com.seleniumtests.driver.BrowserType) OSUtilityFactory(com.seleniumtests.util.osutility.OSUtilityFactory) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Stream(java.util.stream.Stream) Paths(java.nio.file.Paths) Advapi32Util(com.sun.jna.platform.win32.Advapi32Util) Pattern(java.util.regex.Pattern) Collections(java.util.Collections) ConfigurationException(com.seleniumtests.customexception.ConfigurationException) HashMap(java.util.HashMap) Matcher(java.util.regex.Matcher)

Example 20 with ConfigurationException

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

the class BrowserInfo method getDriverFiles.

public List<String> getDriverFiles() throws IOException {
    if (driverList != null) {
        return driverList;
    } else {
        // try to get file names from list generated by maven. In IDE mode, this should not work and we fall back to resource reading
        String driverListFileName = String.format("driver-list-%s.txt", OSUtility.getCurrentPlatorm().toString().toLowerCase());
        try {
            List<String> drivers = new ArrayList<>();
            String[] driverListFromFile = getDriverListFromJarResources(driverListFileName);
            logger.info(String.format("getting drivers from %s", driverListFileName));
            for (String driverNameWithPf : driverListFromFile) {
                if (!driverNameWithPf.startsWith(os)) {
                    continue;
                }
                String driverName = driverNameWithPf.replace(os + "/", "");
                drivers.add(driverName);
            }
            return drivers;
        } catch (NullPointerException | IOException e) {
            // issue #179: due to driver externalization in jars, it's not possible to read them from resources anymore
            throw new ConfigurationException(String.format("Could not read driver from resource file %s, make sure that the dependency seleniumRobot-%s-driver.jar is accessible to robot (in maven repo for developpers and in lib/ folder with classpath option for testers)", driverListFileName, OSUtility.getCurrentPlatorm().toString().toLowerCase()));
        }
    }
}
Also used : ConfigurationException(com.seleniumtests.customexception.ConfigurationException) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Aggregations

ConfigurationException (com.seleniumtests.customexception.ConfigurationException)66 ArrayList (java.util.ArrayList)19 File (java.io.File)18 IOException (java.io.IOException)14 HashMap (java.util.HashMap)13 Test (org.testng.annotations.Test)13 Matcher (java.util.regex.Matcher)9 List (java.util.List)8 UnirestException (kong.unirest.UnirestException)8 GenericTest (com.seleniumtests.GenericTest)7 SeleniumRobotServerException (com.seleniumtests.customexception.SeleniumRobotServerException)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 ScenarioException (com.seleniumtests.customexception.ScenarioException)5 BrowserType (com.seleniumtests.driver.BrowserType)5 Map (java.util.Map)5 Pattern (java.util.regex.Pattern)5 Collectors (java.util.stream.Collectors)5 Win32Exception (com.sun.jna.platform.win32.Win32Exception)4 StandardCharsets (java.nio.charset.StandardCharsets)4 Files (java.nio.file.Files)4