use of com.seleniumtests.customexception.ScenarioException in project seleniumRobot by bhecquet.
the class CustomEventFiringWebDriver method startVideoCapture.
/**
* Start video capture using VideoRecorder class
* @param driverMode
* @param gridConnector
* @param videoName name of the video to record so that it's unique. Only used locally. In remote, grid sessionId is used
*/
public static VideoRecorder startVideoCapture(DriverMode driverMode, SeleniumGridConnector gridConnector, File videoFolder, String videoName) {
if (driverMode == DriverMode.LOCAL) {
try {
VideoRecorder recorder = new VideoRecorder(videoFolder, videoName);
recorder.start();
return recorder;
} catch (HeadlessException e) {
throw new ScenarioException("could not initialize video capture with headless robot: " + e.getMessage());
}
} else if (driverMode == DriverMode.GRID && gridConnector != null) {
gridConnector.startVideoCapture();
return new VideoRecorder(videoFolder, videoName, false);
} else {
throw new ScenarioException("driver supports startVideoCapture only in local and grid mode");
}
}
use of com.seleniumtests.customexception.ScenarioException in project seleniumRobot by bhecquet.
the class CustomEventFiringWebDriver method sendKeysToDesktop.
/**
* send keys to desktop
* This is useful for typing special keys like ENTER
* @param keys List of KeyEvent
*/
public static void sendKeysToDesktop(List<Integer> keyCodes, DriverMode driverMode, SeleniumGridConnector gridConnector) {
if (driverMode == DriverMode.LOCAL) {
try {
Robot robot = new Robot();
WaitHelper.waitForSeconds(1);
for (Integer key : keyCodes) {
robot.keyPress(key);
robot.keyRelease(key);
}
} catch (AWTException e) {
throw new ScenarioException("could not initialize robot to type keys: " + e.getMessage());
}
} else if (driverMode == DriverMode.GRID && gridConnector != null) {
gridConnector.sendKeysWithKeyboard(keyCodes);
} else {
throw new ScenarioException("driver supports sendKeysToDesktop only in local and grid mode");
}
}
use of com.seleniumtests.customexception.ScenarioException in project seleniumRobot by bhecquet.
the class CustomEventFiringWebDriver method uploadFile.
public static void uploadFile(String fileName, String base64Content, DriverMode driverMode, SeleniumGridConnector gridConnector) throws IOException {
if (driverMode == DriverMode.LOCAL) {
byte[] byteArray = base64Content.getBytes();
File tempFile = new File("tmp/" + fileName);
byte[] decodeBuffer = Base64.decodeBase64(byteArray);
FileUtils.writeByteArrayToFile(tempFile, decodeBuffer);
try {
uploadFileUsingClipboard(tempFile);
} catch (IllegalStateException e) {
uploadFileUsingKeyboardTyping(tempFile);
}
} else if (driverMode == DriverMode.GRID && gridConnector != null) {
gridConnector.uploadFileToBrowser(fileName, base64Content);
} else {
throw new ScenarioException("driver supports uploadFile only in local and grid mode");
}
}
use of com.seleniumtests.customexception.ScenarioException in project seleniumRobot by bhecquet.
the class CustomEventFiringWebDriver method doubleClickOnDesktopAt.
public static void doubleClickOnDesktopAt(boolean onlyMainScreen, int x, int y, DriverMode driverMode, SeleniumGridConnector gridConnector) {
if (driverMode == DriverMode.LOCAL) {
try {
Robot robot = new Robot();
if (onlyMainScreen) {
moveMouseMainScreen(robot, x, y);
} else {
moveMouse(robot, x, y);
}
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(10);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
} catch (AWTException e) {
throw new ScenarioException("doubleClickOnDesktopAt: problem using Robot: " + e.getMessage());
}
} else if (driverMode == DriverMode.GRID && gridConnector != null) {
gridConnector.doubleClick(onlyMainScreen, x, y);
} else {
throw new ScenarioException("driver supports doubleClickOnDesktopAt only in local and grid mode");
}
}
use of com.seleniumtests.customexception.ScenarioException in project seleniumRobot by bhecquet.
the class CustomEventFiringWebDriver method rightClicOnDesktopAt.
public static void rightClicOnDesktopAt(boolean onlyMainScreen, int x, int y, DriverMode driverMode, SeleniumGridConnector gridConnector) {
if (driverMode == DriverMode.LOCAL) {
try {
Robot robot = new Robot();
if (onlyMainScreen) {
moveMouseMainScreen(robot, x, y);
} else {
moveMouse(robot, x, y);
}
robot.mousePress(InputEvent.BUTTON2_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON2_DOWN_MASK);
} catch (AWTException e) {
throw new ScenarioException("rightClicOnDesktopAt: problem using Robot: " + e.getMessage());
}
} else if (driverMode == DriverMode.GRID && gridConnector != null) {
gridConnector.rightClic(onlyMainScreen, x, y);
} else {
throw new ScenarioException("driver supports sendKeysToDesktop only in local and grid mode");
}
}
Aggregations