Try to run some appium tests in remote appium server
static String HUB_URL = “http://ie1-abc12-qa.qa.xxx:4444/wd/hub ”;
driver2 = new RemoteWebDriver(new URL(HUB_URL), capabilities);
but I see this error:
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
The selenium grid nodes are up and running on Linux like in this picture:
Giuma
May 29, 2023, 9:10am
2
hi, did you pass the url right? Is the machine you’re pointing to active?
Yes, I can see the nodes in the hub here: “http://ie1-abc12-qa.qa.xxx:4444/wd/hub”;
Giuma
May 29, 2023, 9:48am
4
Have you checked that the remote Appium server is running correctly and that there are no problems starting the server?
@BeforeClass
void beforeClass(@Optional (“platform”) String platform) throws MalformedURLException {
platform = “ios”;
setIosSwiftCaps();
startServer(4723, “127.0.0.1”);
setDriver(platform, “http://127.0.0.1:4723 ”);
}
public void setIosSwiftCaps() {
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "15.5");
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 12 Pro Max");
String appUrlIos = System.getProperty("user.dir") + "/src/app/swift/xxx.app";
capabilities.setCapability("app", appUrlIos);
}
public static void startServer(int appiumPort, String appiumIP) {
AppiumServiceBuilder builder;
log.info("Building and starting the server:");
builder = new AppiumServiceBuilder();
builder.withIPAddress(appiumIP);
builder.usingPort(appiumPort);
builder.withCapabilities(capabilities);
builder.withArgument(GeneralServerFlag.SESSION_OVERRIDE);
builder.withArgument(GeneralServerFlag.LOG_LEVEL, "debug");
service = AppiumDriverLocalService.buildService(builder);
service.start();
log.info("Server started on Port - " + appiumPort + " & IP:" + appiumIP);
}
public void setDriver(String testPlatform, String url) throws MalformedURLException {
if ("ios".equals(testPlatform)) {
System.out.println("------------ios------------");
driver = new AppiumDriver(new URL(url), capabilities);
} else {
System.out.println("------------android------------");
driver = new AndroidDriver(new URL(url), capabilities);
}
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(20));
wait = new WebDriverWait(driver, Duration.ofSeconds(10));
}
public void setDriver(String testPlatform, String url) throws MalformedURLException {
if ("ios".equals(testPlatform)) {
System.out.println("------------ios------------");
driver = new AppiumDriver(new URL(url), capabilities);
} else {
System.out.println("------------android------------");
driver = new AndroidDriver(new URL(url), capabilities);
}
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(20));
wait = new WebDriverWait(driver, Duration.ofSeconds(10));
}
I use this setup to run the tests locally with appium, I want to run the test remote .
Giuma
May 29, 2023, 9:52am
6
this is how i run my test in remote
else if(config.getProperty("browser").equals("remote")){
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-notifications");
options.addArguments("--disable-gpu");
options.addArguments("--disable-extensions");
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
options.addArguments("--remote-allow-origins=*");
try {
driver = new RemoteWebDriver(new URL("http://xxx.xx.x.xxx:4444/wd/hub"),options);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
1 Like
For remote I think I must use RemoteWebDriver with HUB_URL
public void setIosCapsRemote() throws MalformedURLException {
capabilities.setPlatform(Platform.LINUX);
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "15.5");
// capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 12 Pro Max");
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Safari");
String appUrlIos = System.getProperty("user.dir") + "/src/app//........../xxx.app";
capabilities.setCapability("app", appUrlIos);
driver2 = new RemoteWebDriver(new URL(HUB_URL), capabilities);
driver2.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
}