Search in sources :

Example 6 with FactoryRuntimeException

use of ru.sbtqa.tag.pagefactory.exceptions.FactoryRuntimeException in project page-factory-2 by sbtqa.

the class MobileDriverService method mountDriver.

@Override
public void mountDriver() {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, PROPERTIES.getAppiumPlatformName());
    capabilities.setCapability(MobileCapabilityType.APP, PROPERTIES.getAppiumApp());
    capabilities.setCapability(MobileCapabilityType.APPIUM_VERSION, PROPERTIES.getAppiumVersion());
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, PROPERTIES.getAppiumDeviceName());
    capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, PROPERTIES.getAppiumPlatformVersion());
    capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, PROPERTIES.getAppiumBrowserName());
    capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, PROPERTIES.getAppiumAutomationName());
    capabilities.setCapability(MobileCapabilityType.UDID, PROPERTIES.getAppiumUdid());
    capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, PROPERTIES.getNewCommandTimeout());
    capabilities.setCapability(MobileCapabilityType.FULL_RESET, PROPERTIES.getAppiumFullReset());
    capabilities.setCapability(MobileCapabilityType.NO_RESET, PROPERTIES.getAppiumNoReset());
    capabilities.setCapability(IOSMobileCapabilityType.AUTO_ACCEPT_ALERTS, PROPERTIES.getAppiumAlertsAutoAccept());
    capabilities.setCapability("bundleId", PROPERTIES.getAppiumBundleId());
    capabilities.setCapability("appPackage", PROPERTIES.getAppiumAppPackage());
    capabilities.setCapability("appActivity", PROPERTIES.getAppiumAppActivity());
    capabilities.setCapability("permissions", PROPERTIES.getAppiumPermissions());
    capabilities.setCapability("autoGrantPermissions", PROPERTIES.getAppiumAutoGrantPermissions());
    capabilities.setCapability("unicodeKeyboard", PROPERTIES.getAppiumKeyboardUnicode());
    capabilities.setCapability("resetKeyboard", PROPERTIES.getAppiumKeyboardReset());
    capabilities.setCapability("connectHardwareKeyboard", false);
    capabilities.setCapability("xcodeOrgId", PROPERTIES.getAppiumXcodeOrgId());
    capabilities.setCapability("xcodeSigningId", PROPERTIES.getAppiumXcodeSigningId());
    capabilities.setCapability("showIOSLog", PROPERTIES.getAppiumShowIOSLog());
    capabilities.setCapability("appium:disableWindowAnimation", PROPERTIES.getDisableWindowAnimation());
    capabilities.setCapability("appium:useJSONSource", PROPERTIES.getAppiumUseJSONSource());
    capabilities.setCapability("appium:simpleIsVisibleCheck", PROPERTIES.getAppiumSimpleIsVisibleCheck());
    capabilities.setCapability("appium:useNewWDA", PROPERTIES.getAppiumUseNewWDA());
    capabilities.setCapability("appium:usePrebuiltWDA", PROPERTIES.getAppiumUsePrebuiltWDA());
    capabilities.setCapability("appium:derivedDataPath", PROPERTIES.getAppiumDerivedDataPath());
    if (PROPERTIES.getAppiumPlatformName() == ANDROID) {
        capabilities.merge(new SelenoidCapabilitiesParser().parse());
    }
    LOG.info(String.valueOf(capabilities));
    URL url;
    try {
        url = new URL(PROPERTIES.getAppiumUrl());
    } catch (MalformedURLException e) {
        throw new FactoryRuntimeException("Could not parse appium url. Check 'appium.url' property", e);
    }
    mobileDriver = PROPERTIES.getAppiumPlatformName() == IOS ? new IOSDriver(url, capabilities) : new AndroidDriver(url, capabilities);
    if (PROPERTIES.getAppiumPlatformName() == ANDROID) {
        ((AndroidDriver) mobileDriver).setSetting(Setting.WAIT_FOR_IDLE_TIMEOUT, PROPERTIES.getWaitForIdleTimeout());
    }
    if (PROPERTIES.getAppiumVideoEnabled()) {
        appiumVideoRecorder = new AppiumVideoRecorder(Environment.getScenario());
        appiumVideoRecorder.startRecord();
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) IOSDriver(io.appium.java_client.ios.IOSDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) SelenoidCapabilitiesParser(ru.sbtqa.tag.pagefactory.capabilities.SelenoidCapabilitiesParser) AndroidDriver(io.appium.java_client.android.AndroidDriver) FactoryRuntimeException(ru.sbtqa.tag.pagefactory.exceptions.FactoryRuntimeException) AppiumVideoRecorder(ru.sbtqa.tag.pagefactory.mobile.utils.AppiumVideoRecorder) URL(java.net.URL)

Aggregations

FactoryRuntimeException (ru.sbtqa.tag.pagefactory.exceptions.FactoryRuntimeException)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 Method (java.lang.reflect.Method)3 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)2 JDILogger (com.epam.jdi.uitests.core.logger.JDILogger)1 AndroidDriver (io.appium.java_client.android.AndroidDriver)1 IOSDriver (io.appium.java_client.ios.IOSDriver)1 IOException (java.io.IOException)1 SelenoidCapabilitiesParser (ru.sbtqa.tag.pagefactory.capabilities.SelenoidCapabilitiesParser)1 NoSuchActionError (ru.sbtqa.tag.pagefactory.exceptions.NoSuchActionError)1 AppiumVideoRecorder (ru.sbtqa.tag.pagefactory.mobile.utils.AppiumVideoRecorder)1 HtmlElement (ru.yandex.qatools.htmlelements.element.HtmlElement)1