Search in sources :

Example 6 with DriverConfig

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);
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) DriverConfig(com.seleniumtests.driver.DriverConfig) ReplayOnError(com.seleniumtests.uipage.ReplayOnError)

Example 7 with DriverConfig

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());
}
Also used : DriverConfig(com.seleniumtests.driver.DriverConfig) ReplayOnError(com.seleniumtests.uipage.ReplayOnError)

Example 8 with DriverConfig

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);
    }
}
Also used : DriverConfig(com.seleniumtests.driver.DriverConfig) ReplayOnError(com.seleniumtests.uipage.ReplayOnError)

Example 9 with DriverConfig

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));
}
Also used : SeleniumTestsContext(com.seleniumtests.core.SeleniumTestsContext) MutableCapabilities(org.openqa.selenium.MutableCapabilities) DriverConfig(com.seleniumtests.driver.DriverConfig) AndroidCapabilitiesFactory(com.seleniumtests.browserfactory.AndroidCapabilitiesFactory) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 10 with DriverConfig

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));
}
Also used : SeleniumTestsContext(com.seleniumtests.core.SeleniumTestsContext) MutableCapabilities(org.openqa.selenium.MutableCapabilities) DriverConfig(com.seleniumtests.driver.DriverConfig) AndroidCapabilitiesFactory(com.seleniumtests.browserfactory.AndroidCapabilitiesFactory) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

DriverConfig (com.seleniumtests.driver.DriverConfig)18 Test (org.testng.annotations.Test)15 GenericTest (com.seleniumtests.GenericTest)14 AndroidCapabilitiesFactory (com.seleniumtests.browserfactory.AndroidCapabilitiesFactory)11 SeleniumTestsContext (com.seleniumtests.core.SeleniumTestsContext)11 MutableCapabilities (org.openqa.selenium.MutableCapabilities)11 ReplayOnError (com.seleniumtests.uipage.ReplayOnError)3 CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)2 MockitoTest (com.seleniumtests.MockitoTest)1 SeleniumTestsContextManager (com.seleniumtests.core.SeleniumTestsContextManager)1 TestStepManager (com.seleniumtests.core.TestStepManager)1 ScenarioException (com.seleniumtests.customexception.ScenarioException)1 BrowserType (com.seleniumtests.driver.BrowserType)1 DriverExceptionListener (com.seleniumtests.driver.DriverExceptionListener)1 TestType (com.seleniumtests.driver.TestType)1 WebUIDriver (com.seleniumtests.driver.WebUIDriver)1 TestStep (com.seleniumtests.reporter.logger.TestStep)1 StepStatus (com.seleniumtests.reporter.logger.TestStep.StepStatus)1 FrameElement (com.seleniumtests.uipage.htmlelements.FrameElement)1 HtmlElement (com.seleniumtests.uipage.htmlelements.HtmlElement)1