TestProject Forum

AgentConnectException when tried running our selenium web scripts in BS iOS Mobile(emulators) browser

We are trying to run our Selenium-OpenSDK-Web scripts in chrome browser via BrowserStack-iOS mobile emulators(not on real/physical devices). But it keeps failing with AgentConnectException. We know we are missing something in desired capabilities or wrongly setting up mobile browser in browserstack via script, please help us with the correct code. Below is the full code.
The error I am seeing is: “io.testproject.sdk.internal.exceptions.AgentConnectException: Agent responded with status 500: [Could not determine report platform]” on this line of code: “driver = new ChromeDriver(” ********** “,chromeOptions);”

a) Can we run selenium scripts for Mobile browser testing via BS mobile iOS emulator?
b) If Appium is the only way to run scripts in Mobile Browser, atleast using this scripts we’d like to launch the browser in Mobile.

Code:

package gskVaccinationHub;

import java.net.URL;
import java.util.Iterator;
import java.util.List;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import io.testproject.sdk.DriverBuilder;
import io.testproject.sdk.drivers.web.ChromeDriver;
import io.testproject.sdk.drivers.TestProjectCapabilityType;

public class AdultVaccineTrackerWithTestNG2 {

ChromeDriver driver;

@BeforeTest
public void setup() throws Exception {

	String AUTOMATE_USERNAME = "<********>";
	String AUTOMATE_ACCESS_KEY = "<********>";
	String URL = "https://" + AUTOMATE_USERNAME + ":" + AUTOMATE_ACCESS_KEY + "@hub-cloud.browserstack.com/wd/hub";
	ChromeOptions chromeOptions = new ChromeOptions();
	chromeOptions.setCapability(TestProjectCapabilityType.CLOUD_URL,URL);
	chromeOptions.setCapability("browserstack.use_w3c", "true");
	chromeOptions.setCapability("platform", "iOS");
	chromeOptions.setCapability("browserName", "iPhone");
	chromeOptions.setCapability("os_version", "13");
	chromeOptions.setCapability("device", "iPhone 11 Pro");
	chromeOptions.setCapability("realMobile", "false");
	chromeOptions.setCapability("name", "BStack-[Java] Sample Test");
	driver = new DriverBuilder<ChromeDriver>(new ChromeOptions())
			.withRemoteAddress(new URL("http://localhost:8585"))
			.withToken(" ********** ")        
			.build(ChromeDriver.class);
	driver = new ChromeDriver(" ********** ",chromeOptions);
	PageFactory.initElements(driver, this);

	System.out.println("TestProject Setup is done");
}


@FindBy(xpath = "//a[@title='Home']//img[contains(@src,'master/logos')]")
private WebElement adultVaccTrack_HomePage_Logo;


@Test
public void adultVaccineTrackerHeaderAndFooter() throws InterruptedException {

	driver.get("https://gskstaging14:Purpose2021@adultvaccinestracker-com.preprod-cf65.gskinternet.com/");
	waitUntilElementVisible(adultVaccTrack_HomePage_Logo, 20);
	Assert.assertTrue(adultVaccTrack_HomePage_Logo.isDisplayed(), "Adult Vaccine Tracker Home page is not displayed");
	System.out.println("Adult Vaccine Tracker Home page is displayed");
}

public void waitUntilElementVisible(final WebElement element, final int maximumSeconds) {
	WebDriverWait wait = new WebDriverWait(driver, maximumSeconds);
	wait.until(ExpectedConditions.visibilityOf(element));
}

@AfterTest
public void teserDown() throws Exception {
	driver.quit();
}

}

Full Error:
[RemoteTestNG] detected TestNG version 7.4.0
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
FAILED CONFIGURATION: @BeforeTest setup
io.testproject.sdk.internal.exceptions.AgentConnectException: Agent responded with status 500: [Could not determine report platform]
at io.testproject.sdk.internal.rest.AgentClient.handleSessionStartFailure(AgentClient.java:896)
at io.testproject.sdk.internal.rest.AgentClient.startSession(AgentClient.java:695)
at io.testproject.sdk.internal.rest.AgentClient.(AgentClient.java:275)
at io.testproject.sdk.internal.rest.AgentClient.getClient(AgentClient.java:547)
at io.testproject.sdk.drivers.web.ChromeDriver.(ChromeDriver.java:757)
at io.testproject.sdk.drivers.web.ChromeDriver.(ChromeDriver.java:722)
at io.testproject.sdk.drivers.web.ChromeDriver.(ChromeDriver.java:622)
at io.testproject.sdk.drivers.web.ChromeDriver.(ChromeDriver.java:326)
at gskVaccinationHub.AdultVaccineTrackerWithTestNG.setup(AdultVaccineTrackerWithTestNG.java:78)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:385)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:321)
at org.testng.TestRunner.invokeTestConfigurations(TestRunner.java:637)
at org.testng.TestRunner.beforeRun(TestRunner.java:627)
at org.testng.TestRunner.run(TestRunner.java:589)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)
at org.testng.SuiteRunner.run(SuiteRunner.java:276)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
at org.testng.TestNG.runSuites(TestNG.java:1063)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

SKIPPED CONFIGURATION: @AfterTest teserDown
SKIPPED: adultVaccineTrackerHeaderAndFooter
io.testproject.sdk.internal.exceptions.AgentConnectException: Agent responded with status 500: [Could not determine report platform]
at io.testproject.sdk.internal.rest.AgentClient.handleSessionStartFailure(AgentClient.java:896)
at io.testproject.sdk.internal.rest.AgentClient.startSession(AgentClient.java:695)
at io.testproject.sdk.internal.rest.AgentClient.(AgentClient.java:275)
at io.testproject.sdk.internal.rest.AgentClient.getClient(AgentClient.java:547)
at io.testproject.sdk.drivers.web.ChromeDriver.(ChromeDriver.java:757)
at io.testproject.sdk.drivers.web.ChromeDriver.(ChromeDriver.java:722)
at io.testproject.sdk.drivers.web.ChromeDriver.(ChromeDriver.java:622)
at io.testproject.sdk.drivers.web.ChromeDriver.(ChromeDriver.java:326)
at gskVaccinationHub.AdultVaccineTrackerWithTestNG.setup(AdultVaccineTrackerWithTestNG.java:78)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:385)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:321)
at org.testng.TestRunner.invokeTestConfigurations(TestRunner.java:637)
at org.testng.TestRunner.beforeRun(TestRunner.java:627)
at org.testng.TestRunner.run(TestRunner.java:589)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)
at org.testng.SuiteRunner.run(SuiteRunner.java:276)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
at org.testng.TestNG.runSuites(TestNG.java:1063)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

===============================================
Default test
Tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 1

===============================================
Default suite
Total tests run: 1, Passes: 0, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 1

Hi,
Please set up the capabilities like mentioned here:

Let me know if you managed