I am learning Appium, I am unable to create remote session tried changing devices still the same
error message:
An unknown server-side error occurred while processing the command
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'LAPTOP-78EHS656', ip: '192.168.137.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_241'
Driver info: driver.version: AppiumDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output.
at getResponseForW3CError (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:804:9)
here's my code
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
public class AppiumTrialTest {
public static void main(String[] args) throws MalformedURLException {
// TODO Auto-generated method stub
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("deviceName", "Samsung A30");
cap.setCapability("udid", "RR8M70339HL");
cap.setCapability("platformName", "Android");
cap.setCapability("platformVersion", "9"); //android version
cap.setCapability("appPackage", "com.sec.android.app.camera");//ung nasa appinfo apk
cap.setCapability("appActivity", "com.sec.android.app.camera.Camera");
URL url = new URL("http://127.0.0.1:4723/wd/hub");
AppiumDriver driver = new AppiumDriver<MobileElement>(url,cap);
}
}
Related
I'm just a new java developer I'm trying to use the selenium library to do some test cases but I'm experiencing this confusing issue as shown in the image below:
package automationFramework;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class FirstTestCase {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver","chromedriver_win3222\\chromedriver.exe");
WebDriver wd =new ChromeDriver();
String baseUrl = "https://www.google.com";
wd.get(baseUrl);
}
}
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.
Invalid port. Exiting...
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:587)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:264)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:179)
at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:101)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:81)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:49)
at automationFramework.FirstTestCase.main(FirstTestCase.java:13)
Caused by: org.openqa.selenium.WebDriverException: Driver server process died prematurely.
Build info: version: '4.3.0', revision: 'a4995e2c09*'
System info: host: 'DESKTOP-G3NE69C', ip: '192.168.56.1', os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.2'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:226)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:98)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:569)
I can deal with the first error "SLF4J" but I really need other issues to be solved.
This question already has answers here:
Invalid port. Exiting... org.openqa.selenium.os.OsProcess checkForError while launching chrome using selenium
(6 answers)
Closed 2 years ago.
I'm trying to run Selenium Webdriver in chrome Browser using this Java code
using : selenium-java-3.141.59
chrome : 87.0.4280.66
java : 14.0.2
package auto;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class ftst {
#Test
public void test12() throws Exception{
// Initialize browser
WebDriver driver=new ChromeDriver();
// Open Google
driver.get("http://www.google.com");
// Close browser
driver.close();
}
}
But i have this exception
[RemoteTestNG] detected TestNG version 7.3.0
Invalid port. Exiting...
ديسمبر ??, ???? ?:??:?? م org.openqa.selenium.os.OsProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
FAILED: test12
org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'DESKTOP-995VK94', ip: '192.168.209.2', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '14.0.2'
Driver info: driver.version: ChromeDriver
so please help me to solve this problem
Thanks
I never used java, it looks like you didnt set the executable path of the Chromedriver. it needs to be specified in the Chromedriver() bracket, except if the driver is in the same folder as the Java file is
Edit: another solution seems to be the one which was mentioned in the comments, which you can find here
I am automating android using Appium against real devices. I observed that if my script wait for some time, e.g. 10 seconds, then I call driver.currentActivity(). This will cause following Exception:
org.openqa.selenium.WebDriverException: java.net.SocketException: Software caused connection abort: recv failed
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: '', ip: '', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_192'
Driver info: driver.version: AndroidDriver
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:233)
....
Caused by: java.net.SocketException: Software caused connection abort: recv failed
I have tried to google it, but seems no open issue for this. Can anyone suggest what could be wrong? Here is automation script:
public static void main(String[] args) {
try {
DesiredCapabilities oMobileCapability = new DesiredCapabilities();
oMobileCapability.setCapability("deviceName", "****");
oMobileCapability.setCapability("platformName", "Android");
oMobileCapability.setCapability("platform", "Android");
oMobileCapability.setCapability("appPackage", "****");
oMobileCapability.setCapability("appActivity", "****");
oMobileCapability.setCapability("language", "en");
oMobileCapability.setCapability("locale", "US");
oMobileCapability.setCapability("newCommandTimeout", 300);
AndroidDriver<AndroidElement> oDriver;
oDriver = new AndroidDriver<AndroidElement>(new URL ("http://localhost:4723/wd/hub"), oMobileCapability);
Thread.sleep(10000);
System.out.println("Wait Complete!");
System.out.println(oDriver.currentActivity());
oDriver.quit();
} catch (Exception e) {
e.printStackTrace();
}
}
I can see "Wait Complete!", then Exception happens. I am connecting to local Appium node directly.
Appium: v1.9.1
Java: 8
java-client: 6.0.0
Feb 2 UPDATE
This issue was found during trouble shooting this issue:
Appium server automatically quit session while waiting
I've started using selenium over java in eclipse on linux (CentOS 6.6).
With Firefox everything works fine but with Chrome I'm getting:
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'localhost.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-504.el6.x86_64', java.version: '1.7.0_79'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
at First.testGoogleSearch(First.java:24)
at First.main(First.java:18)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'localhost.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-504.el6.x86_64', java.version: '1.7.0_79'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:178)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
... 8 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:13244/status] to be available after 20001 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:107)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:175)
... 11 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:80)
What I've tried:
Changing the SetProperty to path to real path instead of symlink.
That's following additional stack-overflow posts on the issue which suggested the above.
Installing a higher version of Java (using 1.7, installed 1.8).
That's my code, help would be appreciated:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
public class First {
/**
* #param args
* #throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
testGoogleSearch();
}
public static void testGoogleSearch() throws InterruptedException {
//System.setProperty("webdriver.chrome.driver", "//home//shai//selenium//chromedriver");
System.setProperty("webdriver.chrome.driver", "//etc//alternatives//google-chrome");
WebDriver driver = new ChromeDriver();
driver.get("http://some url");
driver.quit();
}
}
There are various possibilities for this issue to occured.
Please check the chromedriver is whether 32 bit or 64 bit. It must match with your OS.
OR
It might be the because of folder permission. Please give execute permission to the folder where chromedriver is located.
I am trying to execute this java code in eclipse, Using Appium and a real device connected using USB. I am unable to lauch the test in the device for an app installed in the device.
package appiumproject;
import io.appium.java_client.android.AndroidDriver;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
public class StartApplication {
private static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException, InterruptedException {
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/sdcard/Android/data/");
File app = new File(appDir, "com.alensw.PicFolder");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "BX9034M10V");
capabilities.setCapability("platformVersion", "4.1.2");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.alensw.PicFolder");
//capabilities.setCapability("appActivity", "com.amazon.mShop.home.HomeActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
Thread.sleep(10000);
driver.quit();
And following is the error I am getting in eclipse console. Can somebody let me know the reason of error : 'Bad app'
How do I give the classPathRoot of app, appActivity from the android device?
}Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Bad app: C:\Users\admin\workspace\AppiumProject\sdcard\Android\data\com.alensw.PicFolder. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Using local app, but didn't end in .zip, .ipa or .apk) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800'
System info: host: 'ADMIN-PC', ip: '10.0.0.63', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_121'
Driver info: driver.version: AndroidDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at io.appium.java_client.remote.AppiumProtocolHandShake.createSession(AppiumProtocolHandShake.java:160)
at io.appium.java_client.remote.AppiumProtocolHandShake.createSession(AppiumProtocolHandShake.java:75)
at io.appium.java_client.remote.AppiumCommandExecutor.doExecute(AppiumCommandExecutor.java:111)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:162)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:88)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:112)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:73)
at appiumproject.StartApplication.main(StartApplication.java:29)
}
In the below capability you need to mention the path of .apk file
capabilities.setCapability("app", app.getAbsolutePath());
It should be like below:
capabilities.setCapability("app","path of apk file");