Selendroid "Error forwarding the new session cannot find : Capabilities" - java

I've got a problem with my selenium config. I'm trying to automate Selenium test on iOS and Android.
The iOS test are running correctly with iOS Driver independently.
The Android test are running correctly independently too.
But when i want to run iOS and Android i've got problems !
For my Android test, i was running this command and everything was fine :
java -jar selendroid-standalone-0.17.0-with-dependencies.jar
But when i want to integrate iOS test, i change the port of this command, following this guide : http://selendroid.io/scale.html
But when I add -port 5555, my Android test fails. With this error :
org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities [{automationName=selendroid, platform=ANDROID, platformName=android, browserName=android, serial=VM-IP}]
I start my config with the following command :
java -cp ios-grid-plugin-0.6.6-SNAPSHOT-4.jar:selenium-server-standalone-2.52.0.jar:selendroid-grid-plugin-0.17.0.jar org.openqa.grid.selenium.GridLauncher -role hub http://192.168.2.33:4444/wd/hub
Am I doing something wrong ?
Thanks for help

Error forwarding the new session cannot find
is the Grid's way of telling you that you are trying to create a new browser session with a capability that the Grid is NOT aware of.
After starting the Selendroid server, did you run the CURL command as documented in this page
curl -H "Content-Type: application/json" -X POST --data #selendroid-nodes-config.json http://localhost:4444/grid/register
Doing this would now force the selendroid server to register itself to the grid running in local host and listening on "4444" and inform the grid that it can service android tests.
Without that, I don't think you can run your Selendroid tests in the Grid mode.

Related

Docker Selenium standalone server is Unable to upload a file to the grid browser in the container

I have a selenium script that to upload an attachment runs on maven and java and is working fine when run from Local.
When I run it on docker container using selenium standalone server receiving the following exception
org.openqa.selenium.InvalidArgumentException: invalid argument: File not found :
Not sure how to resolve it inside the container, I have verified the file is available
The docker compose file Iam using is as follows:
version : '3'
services :
maven:
container_name : Maven-Java
image : maven:3.5.3-jdk-8-alpine
volumes :
- .:/workspace
- ~/.m2:/root/.m2
depends_on :
- selenium
command : mvn -f /workspace test
selenium:
container_name : selenium
image : selenium/standalone-chrome:latest
volumes:
- /dev/shm:/dev/shm
ports :
- 4444:4444
You mounted the volume to container where your test code is running. However you need to mount the volume to the container where the browser is running.
The thing is that when your code says to the web app "hey, this is the file that you need to upload", the test code sends not a file itself but a path that is passed to the browser. Then browser tries to look up that file and build appropriate request to the server.
So the file hast to be within the container where the browser is running.
You need to add a path configuration.
Create a file browsers.json
add this script there
{
"chrome": {
"default": "85.0",
"versions": {
"85.0": {
"image": "selenoid/vnc:chrome_85.0",
"port": "4444",
"volumes": ["/home/ubuntu/your-project:/opt/docker"]
}
}
}
}
and run with this --browsers-json browsers.json argument
this example is for selenoid, but if you don't use selenoid, just add this "volumes": ["/home/ubuntu/your-project:/opt/docker"] to your selenium grid config.
thank you all for the answer's so the working solution I found are two one is as #Alexey mentioned I should also volume map my script folder to the selenium container as well as below:
selenium:
volumes :
- .:/workspace
Above is a docker oriented solution, the other one I found is with selenium grid where the grid can detect the files using a file detector, it can be done by adding the following snipet.
remoteDriver.setFileDetector(new LocalFileDetector());
Both the solutions are working and have solved my problem.

In windows,How to start appium server without mentioning any specific ports and utilize available free ports?

Am using Java code to start Appium server using Command Line Agruments mentioning a specific port in it.Am looking currently how to start the appium server with using available ports in windows machine.
If you have installed the appium using node js then you can start using following command
appium -a 127.0.0.1 -p 4723
If you have download the .exe file then you have to open the executable file and it will show you like this..
then you have to click the start appium server button and if the server start sucessfully then it will look like this..
To start appium service without providing any port, you can use AppiumDriverLocalService class and AppiumServiceBuilder. We will use method 'usingAnyFreePort()' which Configures the appium server to start on any available port. Node.js should be installed on system to achieve it.
We need to provide path of Appium node.exe file path and appium.js file path as below :
String Appium_Node_Path="C:\Program Files\nodejs\node.exe";
//Appium.js file can be available on one of these 2 path
String Appium_JS_Path="C:\Program Files (x86)\Appium\resources\app\node_modules\appium\build\lib/appium.js";
OR
String Appium_JS_Path="C:\Users\username\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\lib\appium.js";
AppiumDriverLocalService appiumService";
appiumService = AppiumDriverLocalService.buildService(new AppiumServiceBuilder().usingAnyFreePort().usingDriverExecutable(new File(Appium_Node_Path)).withAppiumJS(new File(Appium_JS_Path)));
appiumService.start();

selenium tests on safari

I am trying to run my Selenium tests on Safari 11 browser and am unable to launch the browser. I have enabled the Remote automation option in Safari and am tried to launch the browser,But it didn't work as well. I have set up my driver as RemoteWebdriver and I get the error as below:
Possible causes are invalid address of the remote server or browser start-up failure.
Can any one please help?
#jyothi B please run following two commands
/usr/bin/safaridriver --enable
/usr/bin/safaridriver -p 0
and then start your tests.

Java Selenium Using ChromeDriver in Non GUI Env Error : PAC support disabled because there is no system implementation

I just got some trouble when I move my automation test script using Java & Selenium, from my local env (OSX) to my server env (Ubuntu 14 without GUI of course).
So this is the problem.
I try to run my automation test using this command java -jar MyAutomation.jar 3 1 1
3 1 1 is just an application arguments, so there is nothing to do with it in our case.
But after I ran that command, I got my java selenium try to open chrome browser via chromedriver. But unfortunately, this error message has appeared :
PAC support disabled because there is no system implementation
And another error message comes by, here we go :
Exception in thread "main" org.openqa.selenium.WebDriverException:
unknown error: Chrome failed to start: exited abnormally (Driver
info: chromedriver=2.10.267518,platform=Linux 3.13.0-36-generic
x86_64) (WARNING: The server did not provide any stacktrace
information) Command duration or timeout: 60.54 seconds
and of course, I do not know for sure how come it is. But when I try to run in my local env with GUI (in OSX env), it runs without any problem, everything is run well. So in my short analysis, this error comes when I try to run chrome browser in non GUI.
So I try to make some changes in my linux server env. I try to install Xvfb so that my OS works as if there is a GUI control over it.
I start the Xvfb by using this bash script.
I re-run my automation script, and still got the problem. For short insight, I include some snippet here of how I my automation script is.
public void execute(String username, String password){
System.setProperty("webdriver.chrome.driver", "chromedriver");
WebDriver driver = new ChromeDriver();
System.out.println("Try pull all etalase");
ServiceCommonNav.login(driver, username, password);
ServiceCommonNav.moveTo(driver, "https://www.somewebsitetoscrap.com");
Gson gson = new Gson();
List<Etalase> etalases = pullEtalaseList(driver);
SaveEtalaseRequest request = new SaveEtalaseRequest();
request.setEtalases(etalases);
SaveEtalaseWS ws = new SaveEtalaseWS();
ws.call(request);
String json = gson.toJson(etalases);
System.out.println(json);
}
If, if i strongly required to run my scraper over this Xvfb, what is the proper way to achieve that? (So that my opened chrome browser always runs over Xvfb and work as if the browser is headless).
What the step, and what code should I modified to achieve that.
Very beg for your help, I just got stucked for this problem for more than a week. Geez.... :(
Thanks in advance...

Appium \ MAC OS \ Android \ Java - org.openqa.selenium.SessionNotCreatedException

I am trying to test Android device on MAC OS X, using Appium (in Java).
The build path includes these:
java-client-<version>.jar
java-client-<verson>-sources.jar
selenium-java-<version>.jar
selenium-server-standalone-<version>.jar
(the version of the last 2 is the same), and TestNG.
Starting the Appium server (i am using the GUI) works fine and the application (which is already installed on the device) launches. Starting to debug my eclipse project which contains the following lines, i am getting the error for the 3rd line.
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Plus");
AppiumDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
The full error i am getting is:
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. Details: Problem getting session data for driver type AndroidDriver; does it implement 'get driverData'?
You're saying that using the GUI launches the application? If that's the case, and what you're showing in code is your full DesiredCapabilities, then your capabilities would be the problem.
You can see what the capabilities the Appium GUI is using at the top with the text "Launching Appium with command".
If you set those flags in your capabilities, then the driver should connect properly.
You forgot to close the appium session by use driver.close()?
Try to restart your appium server.
P/s: When you don't want to close driver, you need enable Session override in appium GUI settings or add --session-override in appium command line. Then you don't need to restart appium server

Categories

Resources