I am trying to upgrade from Selenium 3 to Selenium 4. The capabilities and everything works fine for all the browsers remotely on sauce labs and works well even on local but when it comes to devices(Android Ipad/Mobile and iOS Ipad/Mobile) I am getting org.openqa.selenium.UnsupportedCommandException. Can someone help out?
- Selenium Version: 4.1.0
- Chrome Driver: 100.0 (latest)
Capabilities
else if (!BaseTest.isLocal && BaseTest.Devices) {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appiumVersion", "1.17.1");
capabilities.setCapability("deviceOrientation", "portrait");
capabilities.setCapability("browserName", browser);
capabilities.setCapability("browserVersion", version);
capabilities.setCapability("platformName", os);
capabilities.setCapability("seleniumVersion", "4.1.0");
capabilities.setCapability("deviceName", devicename);
capabilities.setCapability("platformVersion", platformversion);
capabilities.setCapability("name", methodName);
capabilities.setCapability("autoAcceptAlerts", "true");
System.out.println("pop-up alerts disabled for IOS");
if (browser.toLowerCase().contains("chrome")) {
ChromeOptions options = new ChromeOptions();
options.addArguments("disable-translate");
options.addArguments("disable-translate-new-ux");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
}
if (buildTag != null) {
capabilities.setCapability("build", buildTag);
}
// Launch remote browser and set it as the current thread
webDriver.set(new RemoteWebDriver(
new URL("https://" + username + ":" + accesskey + "@ondemand.saucelabs.com:443/wd/hub"),
capabilities));
Code
private ThreadLocal<WebDriver> webDriver = new ThreadLocal<WebDriver>();
public WebDriver getWebDriver() {
if (!BaseTest.isLocal) {
return webDriver.get();
} else {
return localWebDriver;
}
}
Error
FAILED: Selenium4("Chrome", "latest-1", "Android", "7.1", "Samsung Galaxy Tab A 10 GoogleAPI Emulator", public void com.dell.tnt.tests.WFTTests.Selenium_4_Test.Selenium4(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.reflect.Method) throws java.lang.InterruptedException,com.dell.tnt.exceptions.OfferNotFoundException,java.io.IOException,java.lang.NullPointerException,java.lang.IndexOutOfBoundsException,java.lang.ArrayIndexOutOfBoundsException) org.openqa.selenium.UnsupportedCommandException: The URL '/wd/hub/session/XXXXXXXX-XXXX-XXXX-XXXX-XXXXf7ad4561/window/new' did not map to a valid resource
[ErrorImage][1]
Tried Version:
// Mobile Devices
MutableCapabilities caps = new MutableCapabilities();
caps.setCapability("platformName", os);
caps.setCapability("deviceOrientation", "portrait");
caps.setCapability("browserName", browser);
caps.setCapability("appium:deviceName", devicename);
caps.setCapability("appium:platformVersion", platformversion);
MutableCapabilities sauceOptions = new MutableCapabilities();
sauceOptions.setCapability("name", methodName);
sauceOptions.setCapability("appiumVersion", "1.17.1");
caps.setCapability("sauce:options", sauceOptions);
if (buildTag != null) {
caps.setCapability("build", buildTag);
}
// Launch remote browser and set it as the current thread
webDriver.set(new RemoteWebDriver(
new URL("https://" + username + ":" + accesskey + "@ondemand.saucelabs.com:443" + "/wd/hub"),
caps));
**Error Error1
Saucelab: Saucelab