My test code:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, Platform.ANDROID);
capabilities.setCapability(“deviceName”, “emulator-5556”);
capabilities.setCapability(“automationName”, “UIAutomator2”);
capabilities.setCapability(“app”, “/Users/test/Projects/mobile-test-example/build/wordpress.apk”);
capabilities.setCapability(“appPackage”, “org.wordpress.android”);
capabilities.setCapability(“appActivity”, “org.wordpress.android.ui.WPLaunchActivity”);
final String URL_STRING = "http://127.0.0.1:4723/";
URL url = new URL(URL_STRING);
AndroidDriver driver = new AndroidDriver(url, capabilities);
driver.findElement(By.id("org.wordpress.android:id/nux_username")).sendKeys("[email protected]");
The error return as:
java.lang.ClassCastException: class org.openqa.selenium.Platform$22 cannot be cast to class java.lang.String (org.openqa.selenium.Platform$22 is in unnamed module of loader ‘app’; java.lang.String is in module java.base of loader ‘bootstrap’)
I tried both AppiumDriver and AndroidDriver type but neither worked to me.
Can anyone guide me how did it work? I am facing the same issue and at the same point. I am confuse how to migrate my code to javaclient8 because I am at very beginning of the automation. Anyone can help? Thanks in advance
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import java.net.MalformedURLException;
import java.net.URL;
@ParametersAreNonnullByDefault
public class iOSDriverProvider implements WebDriverProvider {
@Override
@CheckReturnValue
@Nonnull
public WebDriver createDriver(Capabilities capabilities) {
XCUITestOptions options = new XCUITestOptions();
options.merge(capabilities);
options.setAutomationName("XCUITest");
options.setPlatformName("iOS");
options.setDeviceName("iPhone 11");
options.setPlatformVersion("14.1");
options.setApp("/Users/alekseigerasimov/1/UIKitCatalog.app");
System.out.println(options);
try {
return new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), options);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
}
Error: java.lang.ClassCastException: class org.openqa.selenium.Platform$23 cannot be cast to class java.lang.String (org.openqa.selenium.Platform$23 is in unnamed module of loader ‘app’; java.lang.String is in module java.base of loader ‘bootstrap’)