本文整理汇总了Java中org.openqa.selenium.UnsupportedCommandException类的典型用法代码示例。如果您正苦于以下问题:Java UnsupportedCommandException类的具体用法?Java UnsupportedCommandException怎么用?Java UnsupportedCommandException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UnsupportedCommandException类属于org.openqa.selenium包,在下文中一共展示了UnsupportedCommandException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: elementClearOnNonClearableComponents
import org.openqa.selenium.UnsupportedCommandException; //导入依赖的package包/类
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) {
}
}
示例2: isSelectedOnNonSelectableComponents
import org.openqa.selenium.UnsupportedCommandException; //导入依赖的package包/类
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) {
}
}
示例3: handle
import org.openqa.selenium.UnsupportedCommandException; //导入依赖的package包/类
/**
* 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;
}
示例4: processLogEntries
import org.openqa.selenium.UnsupportedCommandException; //导入依赖的package包/类
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!");
}
}
示例5: setPageLoadTimeout
import org.openqa.selenium.UnsupportedCommandException; //导入依赖的package包/类
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 :
}
}
示例6: switchToParentFrame
import org.openqa.selenium.UnsupportedCommandException; //导入依赖的package包/类
/**
* 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();
}
示例7: unsupportedPseudoElement
import org.openqa.selenium.UnsupportedCommandException; //导入依赖的package包/类
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) {
}
}
示例8: handle
import org.openqa.selenium.UnsupportedCommandException; //导入依赖的package包/类
@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;
}
示例9: testSideBarResize
import org.openqa.selenium.UnsupportedCommandException; //导入依赖的package包/类
@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!");
}
示例10: testOverviewLayout
import org.openqa.selenium.UnsupportedCommandException; //导入依赖的package包/类
@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);
}
示例11: setPageLoadTimeout
import org.openqa.selenium.UnsupportedCommandException; //导入依赖的package包/类
protected void setPageLoadTimeout(final long timeout) {
try {
driver.manage().timeouts().pageLoadTimeout(timeout, TimeUnit.SECONDS);
} catch (UnsupportedCommandException e) {
// chromedriver does not support pageLoadTimeout
}
}
示例12: terminate
import org.openqa.selenium.UnsupportedCommandException; //导入依赖的package包/类
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());
}
}
}
示例13: setNetworkConnection
import org.openqa.selenium.UnsupportedCommandException; //导入依赖的package包/类
@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;
}
示例14: testGoNotSupported
import org.openqa.selenium.UnsupportedCommandException; //导入依赖的package包/类
@Test(expected = UnsupportedCommandException.class)
public void testGoNotSupported() {
driver.navigate().to("http://www.google.at");
}
示例15: testGetCurrentUrlNotSupported
import org.openqa.selenium.UnsupportedCommandException; //导入依赖的package包/类
@Test(expected = UnsupportedCommandException.class)
public void testGetCurrentUrlNotSupported() {
driver.getCurrentUrl();
}