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);
}
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);
}
}
Aggregations