public void elementClearOnNonClearableComponents() throws Throwable { driver = new JavaDriver(); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { frame.setLocationRelativeTo(null); frame.setVisible(true); } }); WebElement element1 = driver.findElement(By.name("click-me")); try { element1.clear(); throw new MissingException(UnsupportedCommandException.class); } catch (UnsupportedCommandException e) { } }
public void isSelectedOnNonSelectableComponents() throws Throwable { driver = new JavaDriver(); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { frame.setLocationRelativeTo(null); frame.setVisible(true); } }); WebElement element1 = driver.findElement(By.name("text-field")); try { element1.isSelected(); throw new MissingException(UnsupportedCommandException.class); } catch (UnsupportedCommandException e) { } }
/** * type - {string} The type of operation to set the timeout for. Valid values are: "script" for * script timeouts, "implicit" for modifying the implicit wait timeout and "page load" for setting * a page load timeout. */ @Override public Response handle() throws Exception { JsonObject payload = getRequest().getPayload(); String type = payload.getString("type", ""); final WebDriverLikeCommand command; if ("page load".equals(type)) { command = WebDriverLikeCommand.URL; } else if ("script".equals(type)) { command = WebDriverLikeCommand.EXECUTE_SCRIPT; } else { throw new UnsupportedCommandException("set timeout for " + payload); } long timeout = payload.getJsonNumber("ms").longValue(); getSession().configure(command).set(type, timeout); Response res = new Response(); res.setSessionId(getSession().getSessionId()); res.setStatus(0); res.setValue(new JSONObject()); return res; }
void processLogEntries(ScenarioExecutionContext context, ActionReport actionReport) { try { List<org.openqa.selenium.logging.LogEntry> logEntries = context.getDriver().manage().logs().get(LogType.BROWSER).getAll(); ExecutorOptions options = context.getGlobalContext().getOptions(); // TODO extract mapper List<LogEntry> convertedLogEntries = new ArrayList<>(); for (org.openqa.selenium.logging.LogEntry logEntry : logEntries) { LogLevel actualLevel = convertLogLevel(logEntry.getLevel()); if (LogEntry.isIncluded(options.getBrowserLogLevel(), actualLevel)) { convertedLogEntries.add(new LogEntry( actualLevel, new Date(logEntry.getTimestamp()), logEntry.getMessage())); } } actionReport.setLogEntries(convertedLogEntries); } catch (UnsupportedCommandException e) { // TODO set flag on the report: https://github.com/automate-website/waml-io/issues/2 LOG.warn("Current WebDriver does not support browser logging!"); } }
protected void setPageLoadTimeout(final long timeout, final BrowserType type) { switch (type) { case Chrome : try { driver.manage().timeouts().pageLoadTimeout(timeout, TimeUnit.SECONDS); } catch (UnsupportedCommandException e) { e.printStackTrace(); } break; case FireFox : case InternetExplore : driver.manage().timeouts().pageLoadTimeout(timeout, TimeUnit.SECONDS); break; default : } }
/** * Switch driver focus to the parent of the specified frame context element. * <p> * <b>NOTE</b> This method initially invokes {@code driver.switchTo().parentFrame()}. If that fails with * {@link UnsupportedCommandException}, it invokes {@code element.switchTo()} as a fallback. * * @param element frame context element * @return parent search context */ public static SearchContext switchToParentFrame(RobustWebElement element) { if (canSwitchToParentFrame) { try { return element.getWrappedDriver().switchTo().parentFrame(); } catch (WebDriverException e) { if (Throwables.getRootCause(e) instanceof UnsupportedCommandException) { canSwitchToParentFrame = false; } else { throw e; } } } return element.switchTo(); }
public void unsupportedPseudoElement() throws Throwable { driver = new JavaDriver(); try { driver.findElement(By.cssSelector("#list-1::xth-item(21)")); throw new MissingException(UnsupportedCommandException.class); } catch (UnsupportedCommandException e) { } }
@Override public Response handle() throws Exception { JsonValue p = getRequest().getPayload().get("id"); if (JsonValue.NULL.equals(p)) { getWebDriver().getContext().setCurrentFrame(null, null, null); } else { RemoteWebElement iframe; switch (p.getValueType()) { case NUMBER: iframe = getIframe(((JsonNumber) p).intValue()); break; case OBJECT: String id = ((JsonObject) p).getString("ELEMENT"); iframe = getWebDriver().createElement(id); break; case STRING: iframe = getIframe(((JsonString) p).getString()); break; default: throw new UnsupportedCommandException("cannot select frame by " + p.getClass()); } RemoteWebElement document = iframe.getContentDocument(); RemoteWebElement window = iframe.getContentWindow(); getWebDriver().getContext().setCurrentFrame(iframe, document, window); } Response res = new Response(); res.setSessionId(getSession().getSessionId()); res.setStatus(0); res.setValue(new JSONObject()); return res; }
@Test /** * Ignored because https://github.com/mozilla/geckodriver/issues/233 */ public void testSideBarResize() throws Exception { this.setTestName(getClassname() + "-testSideBarResize"); this.getDriver(); this.getAppController().openViewer(this.getDriver(), getTestDerivate()); ImageViewerController controller = this.getViewerController(); ToolBarController tbController = controller.getToolBarController(); SideBarController sbController = controller.getSideBarController(); tbController.pressButton(ToolBarController.BUTTON_ID_SIDEBAR_CONTROLL); tbController.clickElementById(ImageOverviewController.IMAGE_OVERVIEW_SELECTOR); int sbWidthStart = sbController.getSideBarWidth(); try { // Firefox does not support actions so we just let the test pass. sbController.dragAndDropByXpath("//div[contains(@class,\"sidebar\")]/span[@class=\"resizer\"]", 50, 0); } catch (UnsupportedCommandException e) { LOGGER.warn("Driver does not support Actions", e); return; } int sbWidthEnd = sbController.getSideBarWidth(); assertLess(sbWidthEnd, sbWidthStart, "Sidebar width schould be increased!"); }
@Test public void testOverviewLayout() throws InterruptedException { this.setTestName(getClassname() + "-testOvervieLayout"); this.getDriver(); this.getAppController().openViewer(this.getDriver(), getTestDerivate()); ImageViewerController controller = this.getViewerController(); ToolBarController tbController = controller.getToolBarController(); SideBarController sbController = controller.getSideBarController(); tbController.pressButton(ToolBarController.BUTTON_ID_SIDEBAR_CONTROLL); tbController.clickElementById(ImageOverviewController.IMAGE_OVERVIEW_SELECTOR); int before = sbController.countThumbnails(); try { sbController.dragAndDropByXpath("//div[contains(@class,'sidebar')]/span[@class='resizer']", 300, 0); } catch (UnsupportedCommandException e) { LOGGER.warn("Driver does not support Actions", e); return; } Thread.sleep(1000); int after = sbController.countThumbnails(); Assert.assertEquals(2 * before, after); }
protected void setPageLoadTimeout(final long timeout) { try { driver.manage().timeouts().pageLoadTimeout(timeout, TimeUnit.SECONDS); } catch (UnsupportedCommandException e) { // chromedriver does not support pageLoadTimeout } }
private synchronized void terminate() { Assert.assertTrue(inUse == false); if (driver != null) { try { driver.quit(); if (factory != null) { factory.reportThatDriverQuitSuccessfully(this); } driver = null; // set the driver null so we don't try to use it anymore. } catch (UnsupportedCommandException ex) { LOG.error(ex.toString()); } } }
@Override @Monitor @RetryFailure(retryCount=3) public AppiumDriverController setNetworkConnection(boolean airplaneMode, boolean wifi, boolean data) { if(webDriver() instanceof AndroidDriver) { NetworkConnectionSetting network=new NetworkConnectionSetting(false, true, true); network.setAirplaneMode(airplaneMode); network.setData(data); network.setWifi(wifi); ((AndroidDriver)webDriver()).setNetworkConnection(network); } else { throw new UnsupportedCommandException("The command setNetworkConnection is not used with IOSDriver"); } return this; }
@Test(expected = UnsupportedCommandException.class) public void testGoNotSupported() { driver.navigate().to("http://www.google.at"); }
@Test(expected = UnsupportedCommandException.class) public void testGetCurrentUrlNotSupported() { driver.getCurrentUrl(); }
@Test(expected = UnsupportedCommandException.class) public void testBackNotSupported() { driver.navigate().back(); }
@Test(expected = UnsupportedCommandException.class) public void testForwardNotSupported() { driver.navigate().forward(); }
@Test(expected = UnsupportedCommandException.class) public void testRefreshNotSupported() { driver.navigate().refresh(); }
@Ignore // Ignored for now - delegates to executeScript currently (Selenium // 3.6) which it probably shouldn't @Test(expected = UnsupportedCommandException.class) public void testgetPageSourceNotSupported() { driver.getPageSource(); }
@Test(expected = UnsupportedCommandException.class) public void testFindByCssNotSupported() { driver.findElement(By.cssSelector("test")); }
@Test public void shouldNotThrowErrorIfBrowserLogForwardingIsNotSupportedByTheDriver() { when(logs.get(LogType.BROWSER)).thenThrow(UnsupportedCommandException.class); reporter.processLogEntries(context, actionReport); }
protected void setPageLoadTimeout(final long timeout) { try { driver.manage().timeouts().pageLoadTimeout(timeout, TimeUnit.SECONDS); } catch (UnsupportedCommandException e) { } }
@Test(expected = UnsupportedCommandException.class) public void testShouldNotBeAbleToGoForward() { driver().navigate().forward(); }
@Test(expected = UnsupportedCommandException.class) public void shouldNotRefresh() { driver().navigate().refresh(); }
@Test(expected = UnsupportedCommandException.class) public void shouldNotActivateIMEEngine() { driver().manage().ime().activateEngine("selendroid"); }
@Test(expected = UnsupportedCommandException.class) public void shouldNotDeactivateIME() { driver().manage().ime().deactivate(); }
@Test(expected = UnsupportedCommandException.class) public void shouldNotGetActiveEngine() { driver().manage().ime().getActiveEngine(); }
@Test(expected = UnsupportedCommandException.class) public void shouldNotGetAvailableEngines() { driver().manage().ime().getAvailableEngines(); }
@Test(expected = UnsupportedCommandException.class) public void shouldNotGetActivatedStateOfIME() { driver().manage().ime().isActivated(); }
@Test(expected = UnsupportedCommandException.class) public void shouldNotGetWindowPosition() { driver().manage().window().getPosition(); }
@Test(expected = UnsupportedCommandException.class) public void shouldNotGetWindowsMaximizedState() { driver().manage().window().maximize(); }
@Test(expected = UnsupportedCommandException.class) public void testShouldNotSetPosition() { Point targetPosition = new Point(1, 2); driver().manage().window().setPosition(targetPosition); }
@Test(expected = UnsupportedCommandException.class) public void testShouldNotSetSize() { Dimension targetSize = new Dimension(320, 480); driver().manage().window().setSize(targetSize); }
@Test(expected = UnsupportedCommandException.class) public void shouldNotGoForwardInNativeMode() { openStartActivity(); driver().navigate().forward(); }
@Test(expected = UnsupportedCommandException.class) public void shouldNotDoRefreshInNativeMode() { openStartActivity(); driver().navigate().refresh(); }