Search in sources :

Example 6 with Device

use of com.qaprosoft.carina.core.foundation.webdriver.device.Device in project carina by qaprosoft.

the class DriverPool method restartDriver.

/**
 * Restart default driver on the same device
 *
 * @param isSameDevice
 *            boolean restart driver on the same device or not
 * @return WebDriver
 */
public static WebDriver restartDriver(boolean isSameDevice) {
    WebDriver drv = getDriver(DEFAULT);
    Device device = DevicePool.getNullDevice();
    if (isSameDevice) {
        device = DevicePool.getDevice();
    }
    try {
        LOGGER.debug("Driver restarting...");
        deregisterDriver(DEFAULT);
        if (!isSameDevice) {
            DevicePool.deregisterDevice();
        }
        drv.quit();
        LOGGER.debug("Driver exited during restart...");
    } catch (WebDriverException e) {
        LOGGER.debug("Error message detected during driver restart: " + e.getMessage(), e);
    // do nothing
    } catch (Exception e) {
        LOGGER.debug("Error discovered during driver restart: " + e.getMessage(), e);
        // TODO: it seems like BROWSER_TIMEOUT or NODE_FORWARDING should be handled here as well
        if (!e.getMessage().contains("Session ID is null.")) {
            throw e;
        }
    } finally {
        NDC.pop();
    }
    // start default driver. Device can be nullDevice...
    return createDriver(DEFAULT, null, null, device);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Device(com.qaprosoft.carina.core.foundation.webdriver.device.Device) WebDriverException(org.openqa.selenium.WebDriverException) WebDriverException(org.openqa.selenium.WebDriverException)

Example 7 with Device

use of com.qaprosoft.carina.core.foundation.webdriver.device.Device in project carina by qaprosoft.

the class DriverPool method stopRecording.

private static void stopRecording() {
    if (!Configuration.getBoolean(Parameter.VIDEO_RECORDING)) {
        return;
    }
    Device device = DevicePool.getDevice();
    if (!device.isNull()) {
        device.stopRecording(adbVideoRecorderPid.get());
        // very often video from device is black. waiting
        CommonUtils.pause(3);
        // before pulling the file
        String videoDir = ReportContext.getArtifactsFolder().getAbsolutePath();
        String uniqueFileName = "VIDEO-" + System.currentTimeMillis() + ".mp4";
        device.pullFile(SpecialKeywords.VIDEO_FILE_NAME, videoDir + "/" + uniqueFileName);
        String artifactsLink = ReportContext.getTestArtifactsLink();
        // TODO: use expiration date as current_date + 30
        Artifacts.add("VIDEO", artifactsLink + "/" + uniqueFileName);
    }
}
Also used : Device(com.qaprosoft.carina.core.foundation.webdriver.device.Device)

Aggregations

Device (com.qaprosoft.carina.core.foundation.webdriver.device.Device)7 WebDriver (org.openqa.selenium.WebDriver)2 WebDriverException (org.openqa.selenium.WebDriverException)2 RemoteDevice (com.qaprosoft.carina.commons.models.RemoteDevice)1 Parameter (com.qaprosoft.carina.core.foundation.utils.Configuration.Parameter)1 Type (com.qaprosoft.carina.core.foundation.utils.factory.DeviceType.Type)1 ConfigurationType (com.qaprosoft.zafira.models.dto.config.ConfigurationType)1 AndroidElement (io.appium.java_client.android.AndroidElement)1 IOSDriver (io.appium.java_client.ios.IOSDriver)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)1