How to use UnsupportedCommandException class of org.openqa.selenium package

Best Selenium code snippet using org.openqa.selenium.UnsupportedCommandException

UnsupportedCommandException org.openqa.selenium.UnsupportedCommandException

The WebDriver error - unknown command error, happens when a command or HTTP endpoint is not recognized by the driver.

Examples

A 404 Not Found HTTP status code is returned with the unknown command error when an non-existent /session/{session id}/foo endpoint is accessed:

copy
1% curl -i -d '{}' http://localhost:4444/session/foo 2HTTP/1.1 404 Not Found 3Connection: close 4Content-Type: application/json; charset=utf-8 5Cache-Control: no-cache 6Content-Length: 113 7Date: Fri, 30 Mar 2018 15:30:51 GMT 8 9{"value":{"error":"unknown command","message":"POST /session/asd did not match a known command","stacktrace":""}}

Solutions

  • Change selenium version upgrade/downgrade
  • Use either jsonwire or w3c protocol
  • Refer framwork documentaion for the endpoint

Code Snippets

Here are code snippets that can help you understand more how developers are using

Source:ClosedFiringWebDriver.java Github

copy

Full Screen

...34import org.openqa.selenium.Point;35import org.openqa.selenium.Rotatable;36import org.openqa.selenium.ScreenOrientation;37import org.openqa.selenium.TakesScreenshot;38import org.openqa.selenium.UnsupportedCommandException;39import org.openqa.selenium.WebDriver;40import org.openqa.selenium.WebDriverException;41import org.openqa.selenium.WebElement;42import org.openqa.selenium.interactions.internal.Coordinates;43import org.openqa.selenium.internal.Locatable;44import org.openqa.selenium.internal.WrapsDriver;45import org.openqa.selenium.internal.WrapsElement;46import org.openqa.selenium.logging.Logs;47import org.openqa.selenium.remote.Augmenter;48import org.openqa.selenium.remote.RemoteWebElement;49import org.openqa.selenium.remote.Response;50import org.openqa.selenium.security.Credentials;51import org.openqa.selenium.support.events.EventFiringWebDriver;52import org.primitive.webdriverencapsulations.eventlisteners.IExtendedWebDriverEventListener;53import org.primitive.webdriverencapsulations.interfaces.IComplexFind;54import org.primitive.webdriverencapsulations.interfaces.IGetsAppStrings;55import org.primitive.webdriverencapsulations.interfaces.IGetsNamedTextField;56import org.primitive.webdriverencapsulations.interfaces.IHasActivity;57import org.primitive.webdriverencapsulations.interfaces.IHidesKeyboard;58import org.primitive.webdriverencapsulations.interfaces.IPerformsTouchActions;59import org.primitive.webdriverencapsulations.interfaces.IPinch;60import org.primitive.webdriverencapsulations.interfaces.IScrollsTo;61import org.primitive.webdriverencapsulations.interfaces.ISendsKeyEvent;62import org.primitive.webdriverencapsulations.interfaces.ISendsMetastateKeyEvent;63import org.primitive.webdriverencapsulations.interfaces.IShakes;64import org.primitive.webdriverencapsulations.interfaces.ISwipe;65import org.primitive.webdriverencapsulations.interfaces.ITap;66import org.primitive.webdriverencapsulations.interfaces.IZoom;6768/**69 * @author s.tihomirov For some functions of EventFiringWebDriver70 */71public class ClosedFiringWebDriver extends EventFiringWebDriver72 implements HasCapabilities, MobileDriver, Rotatable, FindsByIosUIAutomation,73 FindsByAndroidUIAutomator, FindsByAccessibilityId, IHasActivity, IPerformsTouchActions, IGetsAppStrings,74 ISendsKeyEvent, ISendsMetastateKeyEvent, ITap, ISwipe, IPinch, IZoom, IScrollsTo, IGetsNamedTextField,75 IHidesKeyboard, IShakes, IComplexFind76 {7778 static class DefaultTimeouts implements Timeouts {79 private Timeouts timeouts;80 private ClosedFiringWebDriver driver;8182 private DefaultTimeouts(Timeouts timeouts,83 ClosedFiringWebDriver driver) {84 this.timeouts = timeouts;85 this.driver = driver;86 }8788 @Override89 public Timeouts implicitlyWait(long arg0, TimeUnit arg1) {90 driver.extendedDispatcher.beforeWebDriverSetTimeOut(91 driver.originalDriver, timeouts, arg0, arg1);92 timeouts.implicitlyWait(arg0, arg1);93 driver.extendedDispatcher.afterWebDriverSetTimeOut(94 driver.originalDriver, timeouts, arg0, arg1);95 return timeouts;96 }9798 @Override99 public Timeouts pageLoadTimeout(long arg0, TimeUnit arg1) {100 driver.extendedDispatcher.beforeWebDriverSetTimeOut(101 driver.originalDriver, timeouts, arg0, arg1);102 timeouts.pageLoadTimeout(arg0, arg1);103 driver.extendedDispatcher.afterWebDriverSetTimeOut(104 driver.originalDriver, timeouts, arg0, arg1);105 return timeouts;106 }107108 @Override109 public Timeouts setScriptTimeout(long arg0, TimeUnit arg1) {110 driver.extendedDispatcher.beforeWebDriverSetTimeOut(111 driver.originalDriver, timeouts, arg0, arg1);112 timeouts.setScriptTimeout(arg0, arg1);113 driver.extendedDispatcher.afterWebDriverSetTimeOut(114 driver.originalDriver, timeouts, arg0, arg1);115 return timeouts;116 }117118 }119120 /**121 * @author s.tihomirov122 * 123 */124 static class DefaultOptions implements Options {125 private Options option;126 private ClosedFiringWebDriver driver;127128 private DefaultOptions(Options option,129 ClosedFiringWebDriver driver) {130 this.option = option;131 this.driver = driver;132 }133134 @Override135 public void addCookie(Cookie cookie) {136 option.addCookie(cookie);137 }138139 @Override140 public void deleteAllCookies() {141 option.deleteAllCookies();142 }143144 @Override145 public void deleteCookie(Cookie cookie) {146 option.deleteCookie(cookie);147 }148149 @Override150 public void deleteCookieNamed(String cookieName) {151 option.deleteCookieNamed(cookieName);152 }153154 @Override155 public Cookie getCookieNamed(String cookieName) {156 return option.getCookieNamed(cookieName);157 }158159 @Override160 public Set<Cookie> getCookies() {161 return option.getCookies();162 }163164 @Override165 public ImeHandler ime() {166 return option.ime();167 }168169 @Override170 @Beta171 public Logs logs() {172 return option.logs();173 }174175 @Override176 public Timeouts timeouts() {177 return new DefaultTimeouts(option.timeouts(),178 driver);179 }180181 @Override182 @Beta183 public Window window() {184 return option.window();185 }186187 }188189 /**190 * @author s.tihomirov191 * 192 */193 static class DefaultTargetLocator implements194 TargetLocator {195 private TargetLocator targetLocator;196 private ClosedFiringWebDriver driver;197198 private DefaultTargetLocator(TargetLocator targetLocator,199 ClosedFiringWebDriver driver) {200 this.targetLocator = targetLocator;201 this.driver = driver;202 }203204 @Override205 public WebElement activeElement() {206 return new DefaultWebElement(207 targetLocator.activeElement(), driver);208 }209210 @Override211 public Alert alert() {212 return new DefaultAlert(targetLocator.alert(), driver);213 }214215 @Override216 public WebDriver defaultContent() {217 targetLocator.defaultContent();218 return driver;219 }220221 @Override222 public WebDriver frame(int arg0) {223 targetLocator.frame(arg0);224 return driver;225 }226227 @Override228 public WebDriver frame(String arg0) {229 targetLocator.frame(arg0);230 return driver;231 }232233 @Override234 public WebDriver frame(WebElement arg0) {235 targetLocator.frame(arg0);236 return driver;237 }238239 @Override240 public WebDriver window(String arg0) {241 targetLocator.window(arg0);242 return driver;243 }244245 @Override246 public WebDriver parentFrame() {247 targetLocator.parentFrame();248 return driver;249 }250251 }252253 /**254 * @author s.tihomirov For some functions of EventFiringWebEvement255 */256 static class DefaultWebElement implements WebElement,257 Locatable, WrapsElement, FindsByAccessibilityId, FindsByAndroidUIAutomator,258 FindsByIosUIAutomation{259 private final WebElement element;260 private WebElement wrapped;261 private ClosedFiringWebDriver extendedDriver;262263 private DefaultWebElement(final WebElement element,264 ClosedFiringWebDriver driver) {265 wrapped = element;266 this.extendedDriver = driver;267 268 this.element = (WebElement) Proxy.newProxyInstance(269 IExtendedWebDriverEventListener.class.getClassLoader(),270 element.getClass().getInterfaces(),271 new InvocationHandler() {272 public Object invoke(Object proxy, Method method,273 Object[] args) throws Throwable {274 try {275 return method.invoke(element, args);276 } catch (InvocationTargetException e) {277 extendedDriver.extendedDispatcher.onException(278 e.getTargetException(),279 extendedDriver.originalDriver);280 throw e.getTargetException();281 }282 }283 });284 }285286 @Override287 public void clear() {288 element.clear();289 }290291 @Override292 public void click() {293 element.click();294 }295296 @Override297 public WebElement findElement(By by) {298 return new DefaultWebElement(element.findElement(by), extendedDriver);299 }300301 @Override302 public List<WebElement> findElements(By by) {303 List<WebElement> temp = element.findElements(by);304 return extendedDriver.getDefaultElementList(temp);305 }306307 @Override308 public String getAttribute(String arg0) {309 return element.getAttribute(arg0);310 }311312 @Override313 public String getCssValue(String arg0) {314 return element.getCssValue(arg0);315 }316317 @Override318 public Point getLocation() {319 return element.getLocation();320 }321322 @Override323 public Dimension getSize() {324 return element.getSize();325 }326327 @Override328 public String getTagName() {329 return element.getTagName();330 }331332 @Override333 public String getText() {334 return element.getText();335 }336337 @Override338 public boolean isDisplayed() {339 return element.isDisplayed();340 }341342 @Override343 public boolean isEnabled() {344 return element.isEnabled();345 }346347 @Override348 public boolean isSelected() {349 return element.isSelected();350 }351352 @Override353 public void sendKeys(CharSequence... arg0) {354 element.sendKeys(arg0);355 }356357 @Override358 public void submit() {359 extendedDriver.extendedDispatcher.beforeSubmit(360 extendedDriver.originalDriver, wrapped);361 element.submit();362 extendedDriver.extendedDispatcher.afterSubmit(363 extendedDriver.originalDriver, wrapped);364 }365366 @Override367 public Coordinates getCoordinates() {368 return ((Locatable) element).getCoordinates();369370 }371372 public WebElement getWrappedElement() {373 return extendedDriver.unpackOriginalElement(wrapped);374 }375376 @Override377 public WebElement findElementByIosUIAutomation(String arg0) {378 MobileElement me = new MobileElement(379 extendedDriver.unpackOriginalElement(wrapped),380 extendedDriver);381 WebElement temp = me.findElementByIosUIAutomation(arg0);382 return new DefaultWebElement(temp, extendedDriver);383 }384385 @Override386 public List<WebElement> findElementsByIosUIAutomation(String arg0) {387 MobileElement me = new MobileElement(388 extendedDriver.unpackOriginalElement(wrapped),389 extendedDriver);390 List<WebElement> temp = me.findElementsByIosUIAutomation(arg0);391 return extendedDriver.getDefaultElementList(temp);392 }393394 @Override395 public WebElement findElementByAndroidUIAutomator(String arg0) {396 MobileElement me = new MobileElement(397 extendedDriver.unpackOriginalElement(wrapped),398 extendedDriver);399 WebElement temp = me.findElementByAndroidUIAutomator(arg0);400 return new DefaultWebElement(temp, extendedDriver);401 }402403 @Override404 public List<WebElement> findElementsByAndroidUIAutomator(String arg0) {405 MobileElement me = new MobileElement(406 extendedDriver.unpackOriginalElement(wrapped),407 extendedDriver);408 List<WebElement> temp = me.findElementsByAndroidUIAutomator(arg0);409 return extendedDriver.getDefaultElementList(temp);410 }411412 @Override413 public WebElement findElementByAccessibilityId(String arg0) {414 MobileElement me = new MobileElement(415 extendedDriver.unpackOriginalElement(wrapped),416 extendedDriver);417 WebElement temp = me.findElementByAccessibilityId(arg0);418 return new DefaultWebElement(temp, extendedDriver);419 }420421 @Override422 public List<WebElement> findElementsByAccessibilityId(String arg0) {423 MobileElement me = new MobileElement(424 extendedDriver.unpackOriginalElement(wrapped),425 extendedDriver);426 List<WebElement> temp = me.findElementsByAccessibilityId(arg0);427 return extendedDriver.getDefaultElementList(temp);428 }429 }430431 /**432 * @author s.tihomirov433 * 434 */435 static class DefaultAlert implements Alert {436 private Alert alert;437 private ClosedFiringWebDriver driver;438439 private DefaultAlert(Alert alert,440 ClosedFiringWebDriver driver) {441 this.alert = alert;442 this.driver = driver;443 }444445 @Override446 public void accept() {447 driver.extendedDispatcher.beforeAlertAccept(448 driver.originalDriver, alert);449 alert.accept();450 driver.extendedDispatcher.afterAlertAccept(451 driver.originalDriver, alert);452 }453454 @Override455 @Beta456 public void authenticateUsing(Credentials arg0) {457 alert.authenticateUsing(arg0);458 }459460 @Override461 public void dismiss() {462 driver.extendedDispatcher.beforeAlertDismiss(463 driver.originalDriver, alert);464 alert.dismiss();465 driver.extendedDispatcher.afterAlertDismiss(466 driver.originalDriver, alert);467 }468469 @Override470 public String getText() {471 return alert.getText();472 }473474 @Override475 public void sendKeys(String arg0) {476 driver.extendedDispatcher.beforeAlertSendKeys(477 driver.originalDriver, alert, arg0);478 alert.sendKeys(arg0);479 driver.extendedDispatcher.afterAlertSendKeys(480 driver.originalDriver, alert, arg0);481 }482483 }484485 private final List<IExtendedWebDriverEventListener> extendedEventListeners = new ArrayList<IExtendedWebDriverEventListener>();486487 private final WebDriver originalDriver;488 private final IExtendedWebDriverEventListener extendedDispatcher = (IExtendedWebDriverEventListener) Proxy489 .newProxyInstance(490 IExtendedWebDriverEventListener.class.getClassLoader(),491 new Class[] { IExtendedWebDriverEventListener.class },492 new InvocationHandler() {493 public Object invoke(Object proxy, Method method,494 Object[] args) throws Throwable {495 for (IExtendedWebDriverEventListener eventListener : extendedEventListeners) {496 method.invoke(eventListener, args);497 }498 return null;499 }500 });501502 ClosedFiringWebDriver(WebDriver driver) {503 super(driver);504 originalDriver = driver;505 }506507 public void register(IExtendedWebDriverEventListener eventListener) {508 super.register(eventListener);509 extendedEventListeners.add(eventListener);510 }511512 public void unregister(IExtendedWebDriverEventListener eventListener) {513 super.unregister(eventListener);514 extendedEventListeners.remove(eventListener);515 }516517 public Capabilities getCapabilities() {518 return ((HasCapabilities) originalDriver).getCapabilities();519 }520521 public WebDriver.TargetLocator switchTo() {522 WebDriver.TargetLocator target = super.switchTo();523 return new DefaultTargetLocator(target, this);524 }525526 public List<WebElement> findElements(By by) {527 List<WebElement> temp = super.findElements(by);528 return getDefaultElementList(temp);529 }530531 public WebElement findElement(By by) {532 WebElement temp = super.findElement(by);533 return new DefaultWebElement(temp, this);534 }535536 public Options manage() {537 Options option = super.manage();538 return new DefaultOptions(option, this);539 }540541 public <X> X getScreenshotAs(OutputType<X> target) {542 X result = null;543 try {544 result = ((TakesScreenshot) originalDriver).getScreenshotAs(target);545 } catch (ClassCastException e) {546 WebDriver augmentedDriver = new Augmenter().augment(originalDriver);547 result = ((TakesScreenshot) augmentedDriver).getScreenshotAs(target);548 }549 return result;550 }551 552 /**553 * It seals wrapped driver forever554 */555 @Deprecated556 @Override557 public WebDriver getWrappedDriver(){558 //I exclude wrapsDriver from this and super class559 Class<?>[] implemented = ClosedFiringWebDriver.class.getInterfaces();560 Class<?>[] implementedBySuper = EventFiringWebDriver.class561 .getInterfaces();562 563 Class<?>[] editedInterfaceArray = new Class<?>[(implemented.length + implementedBySuper.length)-1];564 565 int index = 0;566 for (int i=0; i<implemented.length; i++){567 if (!implemented[i].equals(WrapsDriver.class)){568 editedInterfaceArray[index] = implemented[i]; 569 index++;570 }571 }572 573 for (int i=0; i<implementedBySuper.length; i++){574 if (!implementedBySuper[i].equals(WrapsDriver.class)){575 editedInterfaceArray[index] = implementedBySuper[i]; 576 index++;577 }578 }579580 581 // and create proxy object582 final ClosedFiringWebDriver proxyfied = this;583 WebDriver sealedDriver = (WebDriver) Proxy.newProxyInstance(584 WebDriver.class.getClassLoader(), editedInterfaceArray,585 new InvocationHandler() {586 public Object invoke(Object proxy, Method method,587 Object[] args) throws Throwable {588 try {589 return method.invoke(proxyfied, args);590 } catch (Exception e) {591 throw e;592 }593 }594 });595596 return sealedDriver; 597 }598599 @Override600 public WebDriver context(String name) {601 ((MobileDriver) originalDriver).context(name);602 return this;603 }604605 @Override606 public Set<String> getContextHandles() {607 return ((MobileDriver) originalDriver).getContextHandles();608 }609610 @Override611 public String getContext() {612 return ((MobileDriver) originalDriver).getContext();613 }614615 @Override616 public Response execute(String driverCommand, Map<String, ?> parameters) {617 return ((MobileDriver) originalDriver).execute(driverCommand,618 parameters);619 }620621 @Override622 public TouchAction performTouchAction(TouchAction touchAction) {623 return ((MobileDriver) originalDriver)624 .performTouchAction(touchAction);625 }626627 @Override628 public void performMultiTouchAction(MultiTouchAction multiAction) {629 ((MobileDriver) originalDriver)630 .performMultiTouchAction(multiAction);631 }632633 @Override634 public void rotate(ScreenOrientation orientation) {635 ((Rotatable) originalDriver).rotate(orientation); 636 }637638 @Override639 public ScreenOrientation getOrientation() {640 return ((Rotatable) originalDriver).getOrientation();641 }642643 @Override644 public WebElement findElementByIosUIAutomation(String using) {645 WebElement temp = super.findElement(MobileBy.IosUIAutomation(using));646 return new DefaultWebElement(temp, this);647 }648649 @Override650 public List<WebElement> findElementsByIosUIAutomation(String using) {651 List<WebElement> temp = super.findElements(MobileBy.IosUIAutomation(using));652 return getDefaultElementList(temp);653 }654655 @Override656 public WebElement findElementByAndroidUIAutomator(String using) {657 WebElement temp = super.findElement(MobileBy.AndroidUIAutomator(using));658 return new DefaultWebElement(temp, this);659 }660661 @Override662 public List<WebElement> findElementsByAndroidUIAutomator(String using) {663 List<WebElement> temp = super.findElements(MobileBy.AndroidUIAutomator(using));664 return getDefaultElementList(temp);665 }666667 @Override668 public WebElement findElementByAccessibilityId(String using) {669 WebElement temp = super.findElement(MobileBy.AccessibilityId(using));670 return new DefaultWebElement(temp, this);671 }672673 @Override674 public List<WebElement> findElementsByAccessibilityId(String using) {675 List<WebElement> temp = super.findElements(MobileBy676 .AccessibilityId(using));677 return getDefaultElementList(temp);678 }679 680681 @Override682 public String currentActivity() {683 try {684 return ((AppiumDriver) originalDriver).currentActivity();685 } catch (ClassCastException e) {686 throw new UnsupportedCommandException(687 "Getting activity is not supported by "688 + originalDriver.getClass().getSimpleName());689 }690 catch (WebDriverException e){691 return ""; //iOS Appium tools don't support getting of activity. It is frustrating.692 }693 }694695 @Override696 public String getAppStrings() {697 try {698 return ((AppiumDriver) originalDriver).getAppStrings();699 } catch (ClassCastException e) {700 throw new UnsupportedCommandException(701 "Getting App Strings is not supported");702 }703 }704705 @Override706 public String getAppStrings(String language) {707 try {708 return ((AppiumDriver) originalDriver).getAppStrings(language);709 } catch (ClassCastException e) {710 throw new UnsupportedCommandException(711 "Getting App Strings is not supported. Requred language is " + language);712 }713 }714715 @Override716 public void sendKeyEvent(int key, Integer metastate) {717 try {718 ((AppiumDriver) originalDriver).sendKeyEvent(key, metastate);719 } catch (ClassCastException e) {720 throw new UnsupportedCommandException(721 "Metastate key event sending is not supported.");722 } 723 }724725 @Override726 public void sendKeyEvent(int key) {727 try {728 ((AppiumDriver) originalDriver).sendKeyEvent(key);729 } catch (ClassCastException e) {730 throw new UnsupportedCommandException(731 "Key event sending is not supported.");732 } 733 }734735 @Override736 public void tap(int fingers, WebElement element, int duration) {737 try {738 ((AppiumDriver) originalDriver).tap(fingers, unpackOriginalElement(element), 739 duration);740 } catch (ClassCastException e) {741 throw new UnsupportedCommandException(742 "Tap is not supported.");743 } 744 }745746 @Override747 public void tap(int fingers, int x, int y, int duration) {748 try {749 ((AppiumDriver) originalDriver).tap(fingers, x, y, duration);;750 } catch (ClassCastException e) {751 throw new UnsupportedCommandException(752 "Tap is not supported.");753 }754 }755756 private List<WebElement> getDefaultElementList(List<WebElement> originalList){757 List<WebElement> result = new ArrayList<WebElement>();758 for (WebElement element : originalList) {759 result.add(new DefaultWebElement(element, this));760 }761 return result; 762 }763 764 private RemoteWebElement unpackOriginalElement(WebElement original){765 while (original instanceof WrapsElement) {766 original = ((WrapsElement) original).getWrappedElement(); 767 }768 return (RemoteWebElement) original;769 }770771 @Override772 public void swipe(int startx, int starty, int endx, int endy, int duration) {773 try {774 ((AppiumDriver) originalDriver).swipe(startx, starty, endx, endy, duration);775 } catch (ClassCastException e) {776 throw new UnsupportedCommandException(777 "Swipe is not supported.");778 } 779 }780781 @Override782 public void pinch(WebElement el) {783 try {784 ((AppiumDriver) originalDriver).pinch(unpackOriginalElement(el));785 } catch (ClassCastException e) {786 throw new UnsupportedCommandException(787 "Pinch is not supported.");788 } 789 }790791 @Override792 public void pinch(int x, int y) {793 try {794 ((AppiumDriver) originalDriver).pinch(x,y);795 } catch (ClassCastException e) {796 throw new UnsupportedCommandException(797 "Pinch is not supported.");798 } 799 }800801 @Override802 public void zoom(WebElement el) {803 try {804 ((AppiumDriver) originalDriver).zoom(unpackOriginalElement(el));805 } catch (ClassCastException e) {806 throw new UnsupportedCommandException(807 "Zoom is not supported.");808 } 809 }810811 @Override812 public void zoom(int x, int y) {813 try {814 ((AppiumDriver) originalDriver).zoom(x,y);815 } catch (ClassCastException e) {816 throw new UnsupportedCommandException(817 "Zoom is not supported.");818 } 819 }820821 @Override822 public WebElement scrollTo(String text) {823 try {824 return new DefaultWebElement(((AppiumDriver) originalDriver).scrollTo(text), this);825 } catch (ClassCastException e) {826 throw new UnsupportedCommandException(827 "Scroll is not supported.");828 }829 }830831 @Override832 public WebElement scrollToExact(String text) {833 try {834 return new DefaultWebElement(((AppiumDriver) originalDriver).scrollToExact(text), this);835 } catch (ClassCastException e) {836 throw new UnsupportedCommandException(837 "Scroll to exact is not supported.");838 }839 }840841 @Override842 public void hideKeyboard(String keyName) {843 try {844 ((AppiumDriver) originalDriver).hideKeyboard(keyName);845 } catch (ClassCastException e) {846 throw new UnsupportedCommandException(847 "Keydoard hiding is not supported.");848 } 849 }850851 @Override852 public void hideKeyboard() {853 try {854 ((AppiumDriver) originalDriver).hideKeyboard();855 } catch (ClassCastException e) {856 throw new UnsupportedCommandException(857 "Keydoard hiding is not supported.");858 } 859 }860861 @Override862 public WebElement getNamedTextField(String name) {863 try {864 return new DefaultWebElement(((AppiumDriver) originalDriver).getNamedTextField(name), this);865 } catch (ClassCastException e) {866 throw new UnsupportedCommandException(867 "Named text field getting is not supported.");868 } 869 }870871 @Override872 public void shake() {873 try {874 ((AppiumDriver) originalDriver).shake();875 } catch (ClassCastException e) {876 throw new UnsupportedCommandException(877 "Shaking is not supported.");878 } 879 }880881 @Override882 public WebElement complexFind(String complex) {883 try {884 return new DefaultWebElement(((AppiumDriver) originalDriver).complexFind(complex), this);885 } catch (ClassCastException e) {886 throw new UnsupportedCommandException(887 "Named text field getting is not supported.");888 } 889 } ...

Full Screen

Full Screen

Source:DriverManager.java Github

copy

Full Screen

1package sg.qi.utilities;2import org.openqa.selenium.UnexpectedAlertBehaviour;3import org.openqa.selenium.UnsupportedCommandException;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.chrome.ChromeDriver;6import org.openqa.selenium.chrome.ChromeOptions;7import org.openqa.selenium.edge.EdgeDriver;8import org.openqa.selenium.firefox.FirefoxDriver;9import org.openqa.selenium.firefox.FirefoxOptions;10import org.openqa.selenium.ie.InternetExplorerDriver;11import org.openqa.selenium.ie.InternetExplorerOptions;12import org.openqa.selenium.remote.CapabilityType;13import org.openqa.selenium.safari.SafariDriver;14import java.util.ArrayList;15import java.util.Arrays;16public class DriverManager {17 public DriverManager() throws UnsupportedCommandException {18 if (DriverFactory.getDriver() == null) {19 String browser = System.getProperty("browser");20 WebDriver driver = null;21 try {22 switch (browser) {23 case "chrome": {24 driver = getChromeDriver();25 break;26 }27 case "firefox": {28 driver = getFirefoxDriver();29 break;30 }31 case "ie": {32 driver = getInternetExplorerDriver();33 break;34 }35 case "edge": {36 driver = getEdgeDriver();37 break;38 }39 case "safari": {40 driver = getSafariDriver();41 break;42 }43 }44 driver.manage().window().maximize();45 DriverFactory.addDriver(driver);46 }47 catch (NullPointerException e) {48 String error = "Environment Variable \'browser\' contains an invalid value: " + browser;49 throw new UnsupportedCommandException(error);50 }51 }52 }53 private ChromeDriver getChromeDriver() throws UnsupportedCommandException {54 String driverPath = getExecutablePath() + "chromedriver-" + getSystemArchitecture();55 if (getOperatingSystem().equals("windows")) {56 driverPath = driverPath + ".exe";57 }58 System.setProperty("webdriver.chrome.driver", driverPath);59 ChromeOptions chromeOptions = new ChromeOptions();60 chromeOptions.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);61 return new ChromeDriver(chromeOptions);62 }63 private FirefoxDriver getFirefoxDriver() throws UnsupportedCommandException {64 String driverPath = getExecutablePath() + "geckodriver-" + getSystemArchitecture();65 if (getOperatingSystem().equals("windows")) {66 driverPath = driverPath + ".exe";67 }68 System.setProperty("webdriver.gecko.driver", driverPath);69 FirefoxOptions firefoxOptions = new FirefoxOptions();70 firefoxOptions.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);71 return new FirefoxDriver(firefoxOptions);72 }73 private InternetExplorerDriver getInternetExplorerDriver() throws UnsupportedCommandException {74 String driverPath = getExecutablePath() + "iedriver-" + getSystemArchitecture();75 if (getOperatingSystem().equals("windows")) {76 driverPath = driverPath + ".exe";77 }78 System.setProperty("webdriver.ie.driver", driverPath);79 InternetExplorerOptions internetExplorerOptions = new InternetExplorerOptions();80 internetExplorerOptions.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);81 return new InternetExplorerDriver(internetExplorerOptions);82 }83 private EdgeDriver getEdgeDriver() throws UnsupportedCommandException {84 String error = "Microsoft Edge Browser is not supported";85 throw new UnsupportedCommandException(error);86 }87 private SafariDriver getSafariDriver() throws UnsupportedCommandException {88 String error = "Apple Safari Browser is not supported";89 throw new UnsupportedCommandException(error);90 }91 private String getExecutablePath() throws UnsupportedCommandException {92 String separator = System.getProperty("file.separator");93 if (getOperatingSystem().equals("windows")) {94 separator = separator + System.getProperty("file.separator");95 }96 String suiteHome = System.getProperty("user.dir");97 ArrayList<String> pathParts = new ArrayList<String>(Arrays.asList(suiteHome.split(separator)));98 pathParts.add("drivers");99 pathParts.add(getOperatingSystem());100 pathParts.add("");101 return String.join(separator, pathParts.toArray(new String[0]));102 }103 private String getOperatingSystem() throws UnsupportedCommandException {104 String osName = System.getProperty("os.name").toLowerCase();105 if (osName.contains("win")) {106 return "windows";107 }108 else if (osName.contains("mac")) {109 return "macintosh";110 }111 else if (osName.contains("nix") || osName.contains("nux") || osName.contains("aix")) {112 return "linux";113 }114 else {115 throw new UnsupportedCommandException("Operating System \'" + osName + "\' is not supported");116 }117 }118 private String getSystemArchitecture() throws UnsupportedCommandException {119 String osArch = System.getProperty("os.arch");120 if (osArch.contains("64")) {121 return "64";122 }123 else if (osArch.contains("86")) {124 return "32";125 }126 else {127 throw new UnsupportedCommandException("System Architecture \'" + osArch + "\' is not supported");128 }129 }130}...

Full Screen

Full Screen

Source:UtilsTest.java Github

copy

Full Screen

...22import org.junit.Test;23import org.junit.runner.RunWith;24import org.junit.runners.JUnit4;25import org.openqa.selenium.HasCapabilities;26import org.openqa.selenium.UnsupportedCommandException;27import org.openqa.selenium.WebDriver;28import org.openqa.selenium.html5.AppCacheStatus;29import org.openqa.selenium.html5.ApplicationCache;30import org.openqa.selenium.html5.DatabaseStorage;31import org.openqa.selenium.html5.LocalStorage;32import org.openqa.selenium.html5.Location;33import org.openqa.selenium.html5.LocationContext;34import org.openqa.selenium.html5.SessionStorage;35import org.openqa.selenium.html5.WebStorage;36import org.openqa.selenium.remote.CapabilityType;37import org.openqa.selenium.remote.DesiredCapabilities;38import org.openqa.selenium.remote.DriverCommand;39import org.openqa.selenium.remote.ExecuteMethod;40/**41 * Tests for the {@link Utils} class.42 */43@RunWith(JUnit4.class)44public class UtilsTest {45 @Test46 public void returnsInputDriverIfRequestedFeatureIsImplementedDirectly() {47 WebDriver driver = mock(Html5Driver.class);48 assertSame(driver, Utils.getApplicationCache(driver));49 assertSame(driver, Utils.getLocationContext(driver));50 assertSame(driver, Utils.getDatabaseStorage(driver));51 assertSame(driver, Utils.getWebStorage(driver));52 }53 @Test54 public void throwsIfRequestedFeatureIsNotSupported() {55 WebDriver driver = mock(WebDriver.class);56 try {57 Utils.getApplicationCache(driver);58 fail();59 } catch (UnsupportedCommandException expected) {60 // Do nothing.61 }62 try {63 Utils.getLocationContext(driver);64 fail();65 } catch (UnsupportedCommandException expected) {66 // Do nothing.67 }68 try {69 Utils.getDatabaseStorage(driver);70 fail();71 } catch (UnsupportedCommandException expected) {72 // Do nothing.73 }74 try {75 Utils.getWebStorage(driver);76 fail();77 } catch (UnsupportedCommandException expected) {78 // Do nothing.79 }80 }81 @Test82 public void providesRemoteAccessToAppCache() {83 DesiredCapabilities caps = new DesiredCapabilities();84 caps.setCapability(CapabilityType.SUPPORTS_APPLICATION_CACHE, true);85 CapableDriver driver = mock(CapableDriver.class);86 when(driver.getCapabilities()).thenReturn(caps);87 when(driver.execute(DriverCommand.GET_APP_CACHE_STATUS, null))88 .thenReturn(AppCacheStatus.CHECKING.name());89 ApplicationCache cache = Utils.getApplicationCache(driver);90 assertEquals(AppCacheStatus.CHECKING, cache.getStatus());91 }...

Full Screen

Full Screen

Source:Utils.java Github

copy

Full Screen

...12*/13package shaded.org.openqa.selenium.remote.server.handler.html5;14import com.google.common.base.Throwables;15import org.openqa.selenium.HasCapabilities;16import org.openqa.selenium.UnsupportedCommandException;17import org.openqa.selenium.WebDriver;18import org.openqa.selenium.WebDriverException;19import org.openqa.selenium.html5.ApplicationCache;20import org.openqa.selenium.html5.DatabaseStorage;21import org.openqa.selenium.html5.LocationContext;22import org.openqa.selenium.html5.WebStorage;23import org.openqa.selenium.remote.CapabilityType;24import org.openqa.selenium.remote.ExecuteMethod;25import org.openqa.selenium.remote.html5.RemoteApplicationCache;26import org.openqa.selenium.remote.html5.RemoteDatabaseStorage;27import org.openqa.selenium.remote.html5.RemoteLocationContext;28import org.openqa.selenium.remote.html5.RemoteWebStorage;29import java.lang.reflect.InvocationTargetException;30/**31 * Provides utility methods for converting a {@link WebDriver} instance to the various HTML532 * role interfaces. Each method will throw an {@link UnsupportedCommandException} if the driver33 * does not support the corresponding HTML5 feature.34 */35class Utils {36 static ApplicationCache getApplicationCache(WebDriver driver) {37 return convert(driver, ApplicationCache.class, CapabilityType.SUPPORTS_APPLICATION_CACHE,38 RemoteApplicationCache.class);39 }40 static LocationContext getLocationContext(WebDriver driver) {41 return convert(driver, LocationContext.class, CapabilityType.SUPPORTS_LOCATION_CONTEXT,42 RemoteLocationContext.class);43 }44 static DatabaseStorage getDatabaseStorage(WebDriver driver) {45 return convert(driver, DatabaseStorage.class, CapabilityType.SUPPORTS_SQL_DATABASE,46 RemoteDatabaseStorage.class);47 }48 static WebStorage getWebStorage(WebDriver driver) {49 return convert(driver, WebStorage.class, CapabilityType.SUPPORTS_WEB_STORAGE,50 RemoteWebStorage.class);51 }52 private static <T> T convert(53 WebDriver driver, Class<T> interfaceClazz, String capability,54 Class<? extends T> remoteImplementationClazz) {55 if (interfaceClazz.isInstance(driver)) {56 return interfaceClazz.cast(driver);57 }58 if (driver instanceof ExecuteMethod59 && driver instanceof HasCapabilities60 && ((HasCapabilities) driver).getCapabilities().is(capability)) {61 try {62 return remoteImplementationClazz63 .getConstructor(ExecuteMethod.class)64 .newInstance((ExecuteMethod) driver);65 } catch (InstantiationException e) {66 throw new WebDriverException(e);67 } catch (IllegalAccessException e) {68 throw new WebDriverException(e);69 } catch (InvocationTargetException e) {70 throw Throwables.propagate(e.getCause());71 } catch (NoSuchMethodException e) {72 throw new WebDriverException(e);73 }74 }75 throw new UnsupportedCommandException(76 "driver (" + driver.getClass().getName() + ") does not support "77 + interfaceClazz.getName());78 }79}...

Full Screen

Full Screen

Source:SelendroidUnknownCommandHandlingTest.java Github

copy

Full Screen

...17import org.junit.Ignore;18import org.junit.Test;19import org.openqa.selenium.Dimension;20import org.openqa.selenium.Point;21import org.openqa.selenium.UnsupportedCommandException;22import org.openqa.selenium.WebDriverException;23public class SelendroidUnknownCommandHandlingTest extends BaseAndroidTest {24 @Test(expected = UnsupportedCommandException.class)25 public void testShouldNotBeAbleToGoForward() {26 driver().navigate().forward();27 }28 @Test(expected = UnsupportedCommandException.class)29 public void shouldNotRefresh() {30 driver().navigate().refresh();31 }32 @Test(expected = UnsupportedCommandException.class)33 public void shouldNotActivateIMEEngine() {34 driver().manage().ime().activateEngine("selendroid");35 }36 @Test(expected = UnsupportedCommandException.class)37 public void shouldNotDeactivateIME() {38 driver().manage().ime().deactivate();39 }40 @Test(expected = UnsupportedCommandException.class)41 public void shouldNotGetActiveEngine() {42 driver().manage().ime().getActiveEngine();43 }44 @Test(expected = UnsupportedCommandException.class)45 public void shouldNotGetAvailableEngines() {46 driver().manage().ime().getAvailableEngines();47 }48 @Test(expected = UnsupportedCommandException.class)49 public void shouldNotGetActivatedStateOfIME() {50 driver().manage().ime().isActivated();51 }52 @Test(expected = UnsupportedCommandException.class)53 public void shouldNotGetWindowPosition() {54 driver().manage().window().getPosition();55 }56 @Test(expected = UnsupportedCommandException.class)57 public void shouldNotGetWindowsMaximizedState() {58 driver().manage().window().maximize();59 }60 @Test(expected = UnsupportedCommandException.class)61 public void testShouldNotSetPosition() {62 Point targetPosition = new Point(1, 2);63 driver().manage().window().setPosition(targetPosition);64 }65 @Test(expected = UnsupportedCommandException.class)66 public void testShouldNotSetSize() {67 Dimension targetSize = new Dimension(320, 480);68 driver().manage().window().setSize(targetSize);69 }70 @Test(expected = WebDriverException.class)71 @Ignore("Does not actually throw")72 public void testShouldNotSetPageLoadTimeout() {73 driver().manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);74 }75}...

Full Screen

Full Screen

Source:ExceptionTests.java Github

copy

Full Screen

...6import org.junit.Test;7import org.openqa.selenium.By;8import org.openqa.selenium.NoSuchElementException;9import org.openqa.selenium.StaleElementReferenceException;10import org.openqa.selenium.UnsupportedCommandException;11import org.openqa.selenium.WebDriver;12import org.openqa.selenium.WebElement;13import org.openqa.selenium.remote.DesiredCapabilities;14import org.openqa.selenium.remote.RemoteWebDriver;15public class ExceptionTests {16 private static final String APP = "%WINDIR%\\notepad.exe";17 private WebDriver driver;18 @Before19 public void startApp() throws Exception {20 DesiredCapabilities capabilities = new DesiredCapabilities();21 capabilities.setCapability("app", APP);22 driver = new RemoteWebDriver(new URL("http://localhost:8080"), capabilities);23 }24 @Test(expected = UnsupportedCommandException.class)25 public void testGoNotSupported() {26 driver.navigate().to("http://www.google.at");27 }28 @Test(expected = UnsupportedCommandException.class)29 public void testGetCurrentUrlNotSupported() {30 driver.getCurrentUrl();31 }32 @Test(expected = UnsupportedCommandException.class)33 public void testBackNotSupported() {34 driver.navigate().back();35 }36 @Test(expected = UnsupportedCommandException.class)37 public void testForwardNotSupported() {38 driver.navigate().forward();39 }40 @Test(expected = UnsupportedCommandException.class)41 public void testRefreshNotSupported() {42 driver.navigate().refresh();43 }44 @Ignore // Ignored for now - delegates to executeScript currently (Selenium45 // 3.6) which it probably shouldn't46 @Test(expected = UnsupportedCommandException.class)47 public void testgetPageSourceNotSupported() {48 driver.getPageSource();49 }50 @Test(expected = NoSuchElementException.class)51 public void testNoSuchElementException() throws Exception {52 driver.findElement(By.xpath("//Window[@caption='bla']"));53 }54 @Test(expected = UnsupportedCommandException.class)55 public void testFindByCssNotSupported() {56 driver.findElement(By.cssSelector("test"));57 }58 @Test(expected = StaleElementReferenceException.class)59 public void testStaleElementReferenceException() {60 driver.findElement(By.xpath("//Menu[@caption='Format']")).click();61 driver.findElement(By.xpath("//MenuItem[@caption='Font']")).click();62 WebElement ok = driver.findElement(By.xpath("//PushButton[@caption='OK']"));63 ok.click();64 ok.click(); // Dialog is disposed, button isn't there any more,65 // StaleElementReferenceException should be raised66 }67 @After68 public void closeApp() {...

Full Screen

Full Screen

Source:ProxyServletExceptionsWithoutHubTest.java Github

copy

Full Screen

1package ru.qatools.gridrouter;2import org.junit.Rule;3import org.junit.Test;4import org.openqa.selenium.UnsupportedCommandException;5import org.openqa.selenium.WebDriverException;6import org.openqa.selenium.remote.DesiredCapabilities;7import org.openqa.selenium.remote.RemoteWebDriver;8import ru.qatools.gridrouter.utils.GridRouterRule;9import static org.openqa.selenium.remote.DesiredCapabilities.chrome;10import static org.openqa.selenium.remote.DesiredCapabilities.firefox;11import static ru.qatools.gridrouter.utils.GridRouterRule.hubUrl;12/**13 * @author Innokenty Shuvalov innokenty@yandex-team.ru14 */15public class ProxyServletExceptionsWithoutHubTest {16 @Rule17 public GridRouterRule gridRouter = new GridRouterRule();18 @Test(expected = UnsupportedCommandException.class)19 public void testProxyWithWrongAuth() {20 new RemoteWebDriver(hubUrl(gridRouter.baseUrlWrongPassword), firefox());21 }22 @Test(expected = UnsupportedCommandException.class)23 public void testProxyWithoutAuth() {24 new RemoteWebDriver(hubUrl(gridRouter.baseUrl), firefox());25 }26 @Test(expected = WebDriverException.class)27 public void testProxyWithNotSupportedBrowser() {28 new RemoteWebDriver(hubUrl(gridRouter.baseUrlWithAuth), chrome());29 }30 @Test(expected = WebDriverException.class)31 public void testProxyWithNotSupportedVersion() {32 DesiredCapabilities caps = firefox();33 caps.setVersion("1");34 new RemoteWebDriver(hubUrl(gridRouter.baseUrlWithAuth), caps);35 }36}...

Full Screen

Full Screen

Source:DriverFactory.java Github

copy

Full Screen

1package pl.testeroprogramowania.utils;2import io.github.bonigarcia.wdm.WebDriverManager;3import org.openqa.selenium.UnsupportedCommandException;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.chrome.ChromeDriver;6import org.openqa.selenium.firefox.FirefoxDriver;7public class DriverFactory {8 public static WebDriver getDriver(String name) {9 if(name.equals("firefox")) {10 WebDriverManager.firefoxdriver().setup();11 return new FirefoxDriver();12 } else if (name.equals("chrome")) {13 WebDriverManager.chromedriver().setup();14 return new ChromeDriver();15 } else {16 throw new UnsupportedCommandException("Unsupported browser");17 }18 }19}...

Full Screen

Full Screen

UnsupportedCommandException

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.UnsupportedCommandException;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.WebDriverException;4import org.openqa.selenium.firefox.FirefoxDriver;5import org.openqa.selenium.By;6import org.openqa.selenium.WebElement;7import org.openqa.selenium.interactions.Actions;8import java.util.concurrent.TimeUnit;9public class MouseHover {10 public static void main(String[] args) {11 WebDriver driver = new FirefoxDriver();12 driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);13 WebElement element = driver.findElement(By.linkText("Gmail"));14 Actions builder = new Actions(driver);15 builder.moveToElement(element).build().perform();16 driver.findElement(By.linkText("Sign in")).click();17 driver.close();18 }19}

Full Screen

Full Screen

UnsupportedCommandException

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.UnsupportedCommandException;2import org.openqa.selenium.WebDriverException;3import org.openqa.selenium.remote.DesiredCapabilities;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.remote.RemoteWebDriver;6import java.net.URL;7import java.net.MalformedURLException;8import org.openqa.selenium.By;9import org.openqa.selenium.WebElement;10import org.openqa.selenium.support.ui.ExpectedConditions;11import org.openqa.selenium.support.ui.WebDriverWait;12import java.util.concurrent.TimeUnit;13import org.testng.Assert;14import org.testng.annotations.Test;15import org.testng.annotations.BeforeClass;16import org.testng.annotations.AfterClass;17import org.testng.annotations.BeforeTest;18import org.testng.annotations.AfterTest;19import org.testng.annotations.BeforeMethod;20import org.testng.annotations.AfterMethod;21import org.testng.TestNG;22import java.util.List;23import java.util.ArrayList;24import java.util.Iterator;25import org.openqa.selenium.By;26import org.openqa.selenium.WebElement;27import org.openqa.selenium.support.ui

Full Screen

Full Screen

UnsupportedCommandException

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.UnsupportedCommandException;2import org.openqa.selenium.WebDriverException;3import org.openqa.selenium.NoSuchElementException;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.By;6import org.openqa.selenium.WebElement;7import org.openqa.selenium.chrome.ChromeDriver;8import org.openqa.selenium.remote.DesiredCapabilities;9import org.openqa.selenium.chrome.ChromeOptions;10import java.io.File;11import java.io.IOException;12import java.io.FileInputStream;13import org.apache.poi.xssf.usermodel.XSSFWorkbook;14import org.apache.poi.xssf.usermodel.XSSFSheet;15import org.apache.poi.ss.usermodel.Row;16import org.apache.poi.ss.usermodel.Cell;17import org.apache.poi.ss.usermodel.CellType;18import org.apache.poi.ss.usermodel.DataFormatter;19import java.util.Iterator;20import java.util.ListIterator;21import java.util.ArrayList;22public class TestScript {23 public static void main(String[] args) throws IOException {24 System.setProperty("webdriver.chrome.driver", "C:\\Users\\Rahul\\Downloads\\chromedriver_win32\\chromedriver.exe");25 ChromeOptions options = new ChromeOptions();

Full Screen

Full Screen

UnsupportedCommandException

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.UnsupportedCommandException;2import org.openqa.selenium.WebDriverException;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.WebElement;5import org.openqa.selenium.By;6import org.openqa.selenium.remote.DesiredCapabilities;7import org.openqa.selenium.remote.RemoteWebDriver;8import java.net.URL;9import java.net.MalformedURLException;10import java.io.IOException;11import java.io.File;12import java.io.FileInputStream;13import java.lang.System;14import java.util.Properties;15import java.lang.Thread;16import java.util.concurrent.TimeUnit;17import org.openqa.selenium.support.ui.WebDriverWait;18import org.openqa.selenium.support.ui.ExpectedConditions;19import org.openqa.selenium.support.ui.ExpectedCondition;20import org.openqa.selenium.chrome.ChromeDriver;21import org.openqa.selenium.chrome.ChromeOptions;22import org.openqa.selenium.firefox.FirefoxDriver;23import org.openqa.selenium.firefox.FirefoxProfile;24import org.openqa.selenium.firefox.FirefoxOptions;25import org.openqa.selenium.ie.InternetExplorerDriver;

Full Screen

Full Screen

UnsupportedCommandException

Using AI Code Generation

copy

Full Screen

1package org.openqa.selenium;2import org.openqa.selenium.WebDriverException;3public class UnsupportedCommandException extends WebDriverException {4 public UnsupportedCommandException(String message) {5 super(message);6 }7 public UnsupportedCommandException(String message, Throwable cause) {8 super(message, cause);9 }10}11package com.tutorialspoint;12import org.openqa.selenium.UnsupportedCommandException;13import org.openqa.selenium.WebDriver;14import org.openqa.selenium.WebDriverException;15import org.openqa.selenium.firefox.FirefoxDriver;16public class UnsupportedCommandExceptionDemo {17 public static void main(String[] args) {18 WebDriver driver = new FirefoxDriver();19 try {20 driver.findElement(null);21 } catch (UnsupportedCommandException e) {22 System.out.println("Exception: " + e);23 } finally {24 driver.quit();25 }26 }27}

Full Screen

Full Screen

UnsupportedCommandException

Using AI Code Generation

copy

Full Screen

1import java.io.File;2import java.io.IOException;3import java.util.ArrayList;4import java.util.HashMap;5import java.util.HashSet;6import java.util.Iterator;7import java.util.List;8import java.util.Map;9import java.util.Set;10import java.util.concurrent.TimeUnit;11import org.openqa.selenium.By;12import org.openqa.selenium.JavascriptExecutor;13import org.openqa.selenium.NoSuchElementException;14import org.openqa.selenium.StaleElementReferenceException;15import org.openqa.selenium.TimeoutException;16import org.openqa.selenium.UnexpectedAlertBehaviour;17import org.openqa.selenium.WebDriver;18import org.openqa.selenium.WebDriverException;19import org.openqa.selenium.WebElement;20import org.openqa.selenium.chrome.ChromeDriver;21import org.openqa.selenium.chrome.ChromeDriverService;22import org.openqa.selenium.chrome.ChromeOptions;23import org.openqa.selenium.support.ui.ExpectedConditions;24import org.openqa.selenium.support.ui.WebDriverWait;

Full Screen

Full Screen

UnsupportedCommandException

Using AI Code Generation

copy

Full Screen

1package com.automation;2import org.openqa.selenium.By;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.WebElement;5import org.openqa.selenium.chrome.ChromeDriver;6import org.openqa.selenium.remote.UnreachableBrowserException;7import org.openqa.selenium.remote.UnreachableBrowserException;8public class SeleniumTest {9 public static void main(String[] args) {10 System.setProperty("webdriver.chrome.driver", "C:\\Users\\Administrator\\Downloads\\chromedriver_win32\\chromedriver.exe");11 WebDriver driver = new ChromeDriver();12 WebElement element = driver.findElement(By.name("q"));13 element.sendKeys("Cheese!");14 element.submit();15 System.out.println("Page title is: " + driver.getTitle());16 try {17 driver.close();18 } catch (UnreachableBrowserException e) {19 e.printStackTrace();20 }21 }22}23[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ seleniumtest ---24[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ seleniumtest ---25[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ seleniumtest ---26[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ seleniumtest ---27[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ seleniumtest ---28[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ seleniumtest ---

Full Screen

Full Screen
copy
1public class Test {23 public void firstMoveChoice(){4 System.out.println("First Move");5 } 6 public void secondMOveChoice(){7 System.out.println("Second Move");8 }9 public void thirdMoveChoice(){10 System.out.println("Third Move");11 }1213 public static void main(String[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { 14 Test test = new Test();15 Method[] method = test.getClass().getMethods();16 //firstMoveChoice17 method[0].invoke(test, null);18 //secondMoveChoice19 method[1].invoke(test, null);20 //thirdMoveChoice21 method[2].invoke(test, null);22 }2324}25
Full Screen

Selenium 4 Tutorial:

LambdaTest’s Selenium 4 tutorial is covering every aspects of Selenium 4 testing with examples and best practices. Here you will learn basics, such as how to upgrade from Selenium 3 to Selenium 4, to some advanced concepts, such as Relative locators and Selenium Grid 4 for Distributed testing. Also will learn new features of Selenium 4, such as capturing screenshots of specific elements, opening a new tab or window on the browser, and new protocol adoptions.

Chapters:

  1. Upgrading From Selenium 3 To Selenium 4?: In this chapter, learn in detail how to update Selenium 3 to Selenium 4 for Java binding. Also, learn how to upgrade while using different build tools such as Maven or Gradle and get comprehensive guidance for upgrading Selenium.

  2. What’s New In Selenium 4 & What’s Being Deprecated? : Get all information about new implementations in Selenium 4, such as W3S protocol adaption, Optimized Selenium Grid, and Enhanced Selenium IDE. Also, learn what is deprecated for Selenium 4, such as DesiredCapabilites and FindsBy methods, etc.

  3. Selenium 4 With Python: Selenium supports all major languages, such as Python, C#, Ruby, and JavaScript. In this chapter, learn how to install Selenium 4 for Python and the features of Python in Selenium 4, such as Relative locators, Browser manipulation, and Chrom DevTool protocol.

  4. Selenium 4 Is Now W3C Compliant: JSON Wireframe protocol is retiring from Selenium 4, and they are adopting W3C protocol to learn in detail about the advantages and impact of these changes.

  5. How To Use Selenium 4 Relative Locator? : Selenium 4 came with new features such as Relative Locators that allow constructing locators with reference and easily located constructors nearby. Get to know its different use cases with examples.

  6. Selenium Grid 4 Tutorial For Distributed Testing: Selenium Grid 4 allows you to perform tests over different browsers, OS, and device combinations. It also enables parallel execution browser testing, reads up on various features of Selenium Grid 4 and how to download it, and runs a test on Selenium Grid 4 with best practices.

  7. Selenium Video Tutorials: Binge on video tutorials on Selenium by industry experts to get step-by-step direction from automating basic to complex test scenarios with Selenium.

Selenium 101 certifications:

LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.

Run Selenium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

...Most popular Stackoverflow questions on UnsupportedCommandException

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful