Java Code Examples for com.codeborne.selenide.WebDriverRunner#getWebDriver()
The following examples show how to use
com.codeborne.selenide.WebDriverRunner#getWebDriver() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableImpl.java From masquerade with Apache License 2.0 | 7 votes |
@Override public ElementsCollection selectRows(By rowBy) { this.shouldBe(VISIBLE) .shouldBe(LOADED) .shouldBe(ENABLED); ElementsCollection rows = getRows(rowBy); WebDriver webDriver = WebDriverRunner.getWebDriver(); Actions action = new Actions(webDriver); for (SelenideElement row : rows) { row.shouldNotHave(selectedClass); Keys controlKey = getControlKey(); action.keyDown(controlKey) .click(row.getWrappedElement()) .keyUp(controlKey) .build() .perform(); } return rows; }
Example 2
Source File: BasePage.java From justtestlah with Apache License 2.0 | 6 votes |
/** * Finds the given image within the current screen. * * @param imageName image to check for * @param threshold matching threshold * @return {@link Match} */ public Match findImage(String imageName, double threshold) { WebDriver driver = WebDriverRunner.getWebDriver(); if (driver instanceof TakesScreenshot) { File screenshotFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); if (templateMatcher instanceof AppiumTemplateMatcher) { if (driver instanceof HasSettings) { LOG.info("Setting image matching threshold to {}", threshold); HasSettings settingsDriver = ((HasSettings) driver); settingsDriver.setSetting(Setting.IMAGE_MATCH_THRESHOLD, threshold); } ((AppiumTemplateMatcher) templateMatcher).setDriver(WebDriverRunner.getWebDriver()); } return templateMatcher.match( screenshotFile.getAbsolutePath(), ImageUtils.getFullPath(imageName), threshold); } else { throw new UnsupportedOperationException( "This operation is not supported for the current WebDriver: " + driver.getClass().getSimpleName() + "."); } }
Example 3
Source File: JustTestLahConfiguration.java From justtestlah with Apache License 2.0 | 6 votes |
/** Set the correct {@link org.openqa.selenium.WebDriver}. */ public synchronized void initWebDriver() { // for web and local testing the Selenide default behavior is sufficient System.setProperty("browser", browser); // not thread-safe! Configuration.headless = headless; Platform platform = getPlatform(); if (platform.equals(Platform.ANDROID)) { WebDriverRunner.setWebDriver(webDriverBuilder.getAndroidDriver()); } else if (platform.equals(Platform.IOS)) { WebDriverRunner.setWebDriver(webDriverBuilder.getIOsDriver()); } else if (platform.equals(Platform.WEB)) { if (cloudProvider.equals("browserstack")) { WebDriverRunner.setWebDriver(webDriverBuilder.getWebDriver()); open(baseUrl); } else { open(baseUrl); WebDriverRunner.setWebDriver(webDriverBuilder.getWebDriver()); } } WebDriver driver = WebDriverRunner.getWebDriver(); if (driver instanceof TakesScreenshot) { ocr.setDriver(driver); } }
Example 4
Source File: DataGridImpl.java From masquerade with Apache License 2.0 | 6 votes |
@Override public SelenideElement deselectRow(By rowBy) { this.shouldBe(VISIBLE) .shouldBe(ENABLED); SelenideElement row = getRow(rowBy) .shouldBe(visible) .shouldHave(selectedClass); WebDriver webDriver = WebDriverRunner.getWebDriver(); Actions action = new Actions(webDriver); Keys controlKey = getControlKey(); action.keyDown(controlKey) .click(row.getWrappedElement()) .keyUp(controlKey) .build() .perform(); return row; }
Example 5
Source File: DataGridImpl.java From masquerade with Apache License 2.0 | 6 votes |
@Override public ElementsCollection selectRows(By rowBy) { this.shouldBe(VISIBLE) .shouldBe(LOADED) .shouldBe(ENABLED); ElementsCollection rows = getRows(rowBy); WebDriver webDriver = WebDriverRunner.getWebDriver(); Actions action = new Actions(webDriver); for (SelenideElement row : rows) { row.shouldNotHave(selectedClass); Keys controlKey = getControlKey(); action.keyDown(controlKey) .click(row.getWrappedElement()) .keyUp(controlKey) .build() .perform(); } return rows; }
Example 6
Source File: DataGridImpl.java From masquerade with Apache License 2.0 | 6 votes |
/** * @return control key depending on operating system */ protected Keys getControlKey() { Keys controlKey = Keys.CONTROL; WebDriver webDriver = WebDriverRunner.getWebDriver(); if (webDriver instanceof JavascriptExecutor) { // check if working on MacOS Object result = ((JavascriptExecutor) webDriver) .executeScript("return window.navigator.platform"); if (result instanceof String) { String platform = (String) result; if (MAC_OS_PLATFORM.equals(platform)) { controlKey = Keys.COMMAND; } } } return controlKey; }
Example 7
Source File: TableImpl.java From masquerade with Apache License 2.0 | 6 votes |
@Override public SelenideElement deselectRow(By rowBy) { this.shouldBe(VISIBLE) .shouldBe(ENABLED); SelenideElement row = getRow(rowBy) .shouldBe(visible) .shouldHave(selectedClass); WebDriver webDriver = WebDriverRunner.getWebDriver(); Actions action = new Actions(webDriver); Keys controlKey = getControlKey(); action.keyDown(controlKey) .click(row.getWrappedElement()) .keyUp(controlKey) .build() .perform(); return row; }
Example 8
Source File: TableImpl.java From masquerade with Apache License 2.0 | 6 votes |
/** * @return control key depending on operating system */ protected Keys getControlKey() { Keys controlKey = Keys.CONTROL; WebDriver webDriver = WebDriverRunner.getWebDriver(); if (webDriver instanceof JavascriptExecutor) { // check if working on MacOS Object result = ((JavascriptExecutor) webDriver) .executeScript("return window.navigator.platform"); if (result instanceof String) { String platform = (String) result; if (MAC_OS_PLATFORM.equals(platform)) { controlKey = Keys.COMMAND; } } } return controlKey; }