use of com.seleniumtests.driver.DriverConfig in project seleniumRobot by bhecquet.
the class HtmlElement method simulateClick.
/**
* Click with javascript
*/
@ReplayOnError(waitAfterAction = true)
public void simulateClick() {
if (SeleniumTestsContextManager.isWebTest()) {
((CustomEventFiringWebDriver) updateDriver()).updateWindowsHandles();
}
findElement(true);
outlineElement(getRealElementNoSearch());
DriverConfig driverConfig = WebUIDriver.getWebUIDriver(false).getConfig();
String mouseOverScript;
if ((driverConfig.getBrowserType() == BrowserType.FIREFOX && FirefoxDriverFactory.isMarionetteMode()) || driverConfig.getBrowserType() == BrowserType.EDGE || (driverConfig.getBrowserType() == BrowserType.CHROME && driverConfig.getMajorBrowserVersion() >= 75)) {
mouseOverScript = "var event = new MouseEvent('mouseover', {view: window, bubbles: true, cancelable: true}) ; arguments[0].dispatchEvent(event);";
} else {
mouseOverScript = "if(document.createEvent){var evObj = document.createEvent('MouseEvents');evObj.initEvent('mouseover', true, false); arguments[0].dispatchEvent(evObj);} else if(document.createEventObject) { arguments[0].fireEvent('onmouseover');}";
}
executeScript(mouseOverScript, getRealElementNoSearch());
WaitHelper.waitForSeconds(2);
String clickScript = "";
if ((driverConfig.getBrowserType() == BrowserType.FIREFOX && FirefoxDriverFactory.isMarionetteMode()) || driverConfig.getBrowserType() == BrowserType.EDGE || (driverConfig.getBrowserType() == BrowserType.CHROME && driverConfig.getMajorBrowserVersion() >= 75)) {
clickScript = "var event = new MouseEvent('click', {view: window, bubbles: true, cancelable: true}) ;" + "arguments[0].dispatchEvent(event);";
} else {
clickScript = "if(document.createEvent){var evObj = document.createEvent('MouseEvents');evObj.initEvent('click', true, false); arguments[0].dispatchEvent(evObj);} else if(document.createEventObject) { arguments[0].fireEvent('onclick');}";
}
executeScript(clickScript, getRealElementNoSearch());
WaitHelper.waitForSeconds(2);
}
use of com.seleniumtests.driver.DriverConfig in project seleniumRobot by bhecquet.
the class HtmlElement method simulateDoubleClick.
@ReplayOnError(waitAfterAction = true)
public void simulateDoubleClick() {
findElement(true);
outlineElement(getRealElementNoSearch());
DriverConfig driverConfig = WebUIDriver.getWebUIDriver(false).getConfig();
String doubleClickScript;
if ((driverConfig.getBrowserType() == BrowserType.FIREFOX && FirefoxDriverFactory.isMarionetteMode()) || driverConfig.getBrowserType() == BrowserType.EDGE || (driverConfig.getBrowserType() == BrowserType.CHROME && driverConfig.getMajorBrowserVersion() >= 75)) {
doubleClickScript = "var event = new MouseEvent('dblclick', {view: window, bubbles: true, cancelable: true}) ;" + "arguments[0].dispatchEvent(event);";
} else {
doubleClickScript = JS_CLICK_DOUBLE;
}
executeScript(doubleClickScript, getRealElementNoSearch());
}
use of com.seleniumtests.driver.DriverConfig in project seleniumRobot by bhecquet.
the class HtmlElement method simulateSendKeys.
@ReplayOnError(waitAfterAction = true)
public void simulateSendKeys(CharSequence... keysToSend) {
findElement(true);
// click on element before sending keys through keyboard
getRealElementNoSearch().click();
executeScript("arguments[0].focus();", getRealElementNoSearch());
DriverConfig driverConfig = WebUIDriver.getWebUIDriver(false).getConfig();
// sendKeysToActiveElement which are not available for firefox and IE
if ((driverConfig.getBrowserType() == BrowserType.FIREFOX && FirefoxDriverFactory.isMarionetteMode()) || driverConfig.getBrowserType() == BrowserType.INTERNET_EXPLORER || driverConfig.getBrowserType() == BrowserType.EDGE || (driverConfig.getBrowserType() == BrowserType.CHROME && driverConfig.getMajorBrowserVersion() >= 75)) {
logger.warn("using specific Marionette method");
executeScript(String.format("arguments[0].value='%s';", keysToSend[0].toString()), getRealElementNoSearch());
} else {
// use keyboard to type
((CustomEventFiringWebDriver) getDriver()).getKeyboard().sendKeys(keysToSend);
}
}
use of com.seleniumtests.driver.DriverConfig in project seleniumRobot by bhecquet.
the class TestAndroidCapabilitiesFactory method testCreateDefaultChromeCapabilities.
/**
* Check default behaviour
*/
@Test(groups = { "ut" })
public void testCreateDefaultChromeCapabilities() {
SeleniumTestsContext context = new SeleniumTestsContext(SeleniumTestsContextManager.getThreadContext());
context.setBrowser(BrowserType.CHROME.toString());
context.setMobilePlatformVersion("8.0");
context.setPlatform("android");
context.setDeviceName("Samsung Galasy S8");
context.setApp("");
DriverConfig config = new DriverConfig(context);
AndroidCapabilitiesFactory capaFactory = new AndroidCapabilitiesFactory(config);
MutableCapabilities capa = capaFactory.createCapabilities();
Assert.assertEquals(capa.getCapability(CapabilityType.BROWSER_NAME), BrowserType.CHROME.toString().toLowerCase());
Assert.assertEquals(capa.getCapability(MobileCapabilityType.AUTOMATION_NAME), "Appium");
Assert.assertEquals(capa.getCapability(MobileCapabilityType.PLATFORM_NAME), "android");
Assert.assertEquals(capa.getCapability(MobileCapabilityType.PLATFORM_VERSION), "8.0");
Assert.assertEquals(capa.getCapability(MobileCapabilityType.DEVICE_NAME), "Samsung Galasy S8");
Assert.assertFalse(capa.is(SeleniumRobotCapabilityType.NODE_TAGS));
// from exampleConfigGenericParams.xml when tu.xml is executed, else, null
Assert.assertEquals(capa.getCapability(AndroidMobileCapabilityType.APP_PACKAGE), "com.infotel.mobile");
// from exampleConfigGenericParams.xml when tu.xml is executed, else, null
Assert.assertEquals(capa.getCapability(AndroidMobileCapabilityType.APP_ACTIVITY), "com.infotel.mobile.StartActivity");
Assert.assertNull(capa.getCapability(MobileCapabilityType.FULL_RESET));
}
use of com.seleniumtests.driver.DriverConfig in project seleniumRobot by bhecquet.
the class TestAndroidCapabilitiesFactory method testCreateDefaultCapabilitiesWithNodeTagsInLocalMode.
/**
* Check default behaviour when node tags are defined in local mode
* tags are not transferred to driver
*/
@Test(groups = { "ut" })
public void testCreateDefaultCapabilitiesWithNodeTagsInLocalMode() {
SeleniumTestsContext context = new SeleniumTestsContext(SeleniumTestsContextManager.getThreadContext());
context.setBrowser(BrowserType.CHROME.toString());
context.setNodeTags("foo,bar");
context.setRunMode("local");
context.setMobilePlatformVersion("8.0");
context.setPlatform("android");
context.setDeviceName("Samsung Galasy S8");
context.setApp("");
DriverConfig config = new DriverConfig(context);
AndroidCapabilitiesFactory capaFactory = new AndroidCapabilitiesFactory(config);
MutableCapabilities capa = capaFactory.createCapabilities();
Assert.assertFalse(capa.is(SeleniumRobotCapabilityType.NODE_TAGS));
}
Aggregations