36117

Exception in thread “main” org.openqa.selenium.WebDriverException

I'm trying to test my application in eclipse IDE using java throwing this error. I started appium server also. gave matching port numbers too. this is my log trace. help me out.Thanks in advance

This is the code I used for testing my android app using appium:

public class MilonowFirstTest { static AppiumDriver<WebElement> driver; // @BeforeClass public static void main(String[] args) throws MalformedURLException //public void Setup() throws MalformedURLException { DesiredCapabilities cap = new DesiredCapabilities(); //cap.setCapability(AndroidMobileCapabilityType.De, value); cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Android emulator"); //cap.setCapability(MobileCapabilityType.APP_PACKAGE, value); cap.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "com.test.myapp"); //cap.setCapability(MobileCapabilityType.APP, ""); cap.setCapability("avd", "Honor 7X API 27"); cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android"); cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, "23"); cap.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Appium"); driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wb/hub"), cap); Assert.assertNotNull(driver.getContext()); } // @Test() // public void SimpleTest() // { // Assert.assertNotNull(driver.getContext()); // } }

Error log:

Exception in thread "main" org.openqa.selenium.WebDriverException: It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found or it is not accessible Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:03.216Z' System info: host: 'DESKTOP-4DSS7OC', ip: '192.168.2.21', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_161' Driver info: driver.version: AndroidDriver at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:195) at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:209) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:231) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543) 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:207) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130) at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:38) at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:84) at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:94) at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:93) at testcase.MilonowFirstTest.main(MilonowFirstTest.java:37) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:185) ... 13 more Caused by: org.openqa.selenium.WebDriverException: Unable to parse remote response: The URL '/wb/hub/session' did not map to a valid resource Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:03.216Z' System info: host: 'DESKTOP-4DSS7OC', ip: '192.168.2.21', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_161' Driver info: driver.version: AndroidDriver at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:111) ... 18 more

Answer1:

Close the appium server and start it again, this should work. The permanent solution for this problem is:

    <li>Start Appium app</li> <li>Go to advance setting</li> <li>enter server address and server port that you want. I am using 127.0.0.1 as server address and 4723 as server port</li> <li>Select or check session Override</li> </ul>

    If you like you can save this configuration as preset for using next time. Also include following desire capabilities in your app

    AppiumDriver<MobileElement> driver; DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability("deviceName", "Android phone"); caps.setCapability("udid", "your device uuid"); caps.setCapability("platformName", "Android"); caps.setCapability("platformVersion", "your device version"); caps.setCapability("appPackage", "name of app package"); caps.setCapability("appActivity", "name of app activity"); driver=new AndroidDriver<MobileElement>(new URL( "http://127.0.0.1:4723/wd/hub"), caps);

    <strong>How to find device uuid?</strong>

      <li>Enable usb debugging mode in your android device and connect to your laptop</li> <li>Open command prompt and type adb devices</li> </ul>

      It will show the list of connected devices to your laptop. Below List of devices attached you can find your device uuid

      <strong>How to find appPackage and appActivity</strong>

      click here: How to find appPackage and appActivity?

      Answer2:

      Try by putting in desired capabilities parameter "APP",

      cap.setCapability(MobileCapabilityType.APP, "path_to_your_app");

      or as You started with a matched in-pair caps, if application is already installed on your device:

      cap.setCapability("appActivity", "com.test.myapp.ui.activities.MainActivity"); cap.setCapability("appPackage", "com.test.myapp");

      and You can check Your activity and package name with this command, by opening application on Your phone and going to console and run this:

      adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'

      this will return something like this:

      mCurrentFocus=Window{5f6bfe8 u0 d0 abc.com.test.android/com.test.abc.ui.home.HomeActivity} mFocusedApp=AppWindowToken{123d4faf token=Token{asd2342 ActivityRecord{323tgee3 u0 abc.com.test.android/com.test.abc.ui.home.HomeActivity t1732}}}

      where as follows:

      Window{5f6bfe8 u0 d0 abc.com.test.android/com.test.abc.ui.home.HomeActivity}

      activity: `

      "abc.com.test.android"

      ...and is a package

      "com.test.abc.ui.home.HomeActivity"

      but recommended to put all params in the mix APP, APP_PACKAGE, APP_ACTIVITY

      hope this helps,

      Answer3:

      You are calling

      driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wb/hub"), cap);

      Correct URL should be <strong>/wd/hub</strong>.

Recommend

  • activemq User is not authorized to create: topic://ActiveMQ.Advisory.Connection
  • Firefox Selenium Driver fails to load arbitarily
  • Send and Receive XML formatted text to IBM WebSphere MQ using XMS
  • Error with selenium firefox webdriver
  • UWP: Upload large files to OneDrive using OneDrive SDK
  • Lotus Notes Java API. Mail forwarding
  • how to start a countdown timer from 1 controller and displayed in the other-angularjs
  • Automate browser actions - Clicking the submit button errors - “Click succeeded but Load Failed. ..”
  • ActiveMQ How to handle closed session
  • Passing a string value to Javascript Executor in selenium
  • Collect and run all junit tests in parallel with each test class in its own JVM (parallelization by
  • how to avoid the dependencies hell with unit test in angular 2+
  • WSO2 ESB 4.0.3 - Error installing Data Services feature from 4.0.* repositories
  • How to make http call with file in groovy to upload a file and build arguments
  • Quickly or concisely determine the longest string per column in a row-based data collection
  • MonadTransControl instance for ProxyFast/ProxyCorrect
  • Appium MobileElement swipe returns unknown server error
  • Is there a package like bigmemory in R that can deal with large list objects?
  • Detecting null parameter in preprocessor macro
  • Sending cookie value via httpget but not getting the desired response
  • Azure webjobs output logs indexing taking very long
  • SQLite connection strategies
  • ADO and msqli connections very slow
  • How can I extract results of aggregate queries in slick?
  • Marklogic : Query response time is very high
  • How to use remove-erase idiom for removing empty vectors in a vector?
  • Seeking advice on Jetty HttpClient Hang
  • Debugging ASP.NET on a built-in web server suddenly stops
  • PHP - How to update data to MySQL when click a radio button
  • Counter field in MS Access, how to generate?
  • Get object from AWS S3 as a stream
  • Java applet as stand-alone Windows application?
  • MySQL WHERE-condition in procedure ignored
  • Adding custom controls to a full screen movie
  • Comma separated Values
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • Error creating VM instance in Google Compute Engine
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]
  • How to get NHibernate ISession to cache entity not retrieved by primary key