java-opensdk
java-opensdk copied to clipboard
Unable to run tests on mobile devices on BrowserStack
Hi Team,
I was trying to setup testproject open sdk to run tests on browserstack cloud devices. I am able to run tests successfully on desktop browsers but when I try to run on mobile device browsers by setting capabilities as shown below I get the following error
Exception in thread "main" java.lang.ClassCastException: class com.google.gson.internal.LinkedTreeMap cannot be cast to class java.lang.String (com.google.gson.internal.LinkedTreeMap is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
at org.openqa.selenium.AbstractCapabilities.setCapability(AbstractCapabilities.java:77)
at org.openqa.selenium.MutableCapabilities.setCapability(MutableCapabilities.java:100)
at org.openqa.selenium.MutableCapabilities.lambda$new$0(MutableCapabilities.java:54)
at java.base/java.util.Map.forEach(Map.java:661)
at org.openqa.selenium.MutableCapabilities.<init>(MutableCapabilities.java:52)
at io.testproject.sdk.internal.rest.AgentClient.startSession(AgentClient.java:723)
at io.testproject.sdk.internal.rest.AgentClient.<init>(AgentClient.java:275)
at io.testproject.sdk.internal.rest.AgentClient.getClient(AgentClient.java:547)
at io.testproject.sdk.drivers.web.RemoteWebDriver.<init>(RemoteWebDriver.java:718)
at io.testproject.sdk.drivers.web.RemoteWebDriver.<init>(RemoteWebDriver.java:634)
at io.testproject.sdk.drivers.web.RemoteWebDriver.<init>(RemoteWebDriver.java:331)
at com.browserstack.WebTest.main(WebTest.java:49)
The device is launched on Browserstack but after that this error pops up here is the Public URL to the session
This is my code to start the Driver using Testproject SDK Platform[] platforms = {Platform.ANDROID}; for(Platform platform : platforms) {
// setting up driver
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setCapability(TestProjectCapabilityType.CLOUD_URL, URL);
chromeOptions.setCapability(CapabilityType.PLATFORM_NAME, platform);
chromeOptions.setCapability("osVersion", "10.0");
chromeOptions.setCapability("deviceName", "Samsung Galaxy S20");
RemoteWebDriver driver = new RemoteWebDriver("5Ppy08u_qdvqmX2ZJGE2Ttld1Wft8Rq1tn38rDqZ6Cs1", chromeOptions, "BS Local Examples");
driver.get("www.google.com");
driver.quit();
}
It seems like the error is originated from the Testproject SDK, I will be happy to create a pull request to fix this issue if someone can guide me what is causing this error.
Thanks & Regards