5

I am using selendroid to test android app. Everything works fine till login click/tap. Once I Tap/Click on login button it close my android application and does not return any error.

My code is given below :

public class androidaut {

public static void main(String[] args) throws Exception{

    try{

     // specify test capabilities (your 'test environment')
    SelendroidCapabilities capa = new SelendroidCapabilities("air.iNMyBabyPaid:1.3.0");     

    // Set device serial to get device
    capa.setSerial("192.168.xx.xx:xxxx");

    // Set device capability for platform version
    capa.setCapability("platformVersion", "17");


    // explicitly state that we use an emulator (an AVD) for test execution rather than a physical device
    capa.setEmulator(false);



    // start a new WebDriver
    WebDriver driver = new SelendroidDriver(capa);
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);


    // Enter user name
    WebElement username = driver.findElement(By.xpath("(//EditText)[1]"));
    username.click();
    username.sendKeys("tester");


    // Enter password
    WebElement pass = driver.findElement(By.xpath("(//EditText)[2]"));
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    pass.click();
    pass.sendKeys("stester#");

    // Get Login element 
    WebElement login = driver.findElement(By.id("llSignIn"));



    // Click on Login button
    if(login.isEnabled())
    {
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        login.click();
        //System.out.println(((RemoteWebDriver) driver).getSessionId());

    }
    else
    {

        System.out.println("Sorry! Your login button is disabled");
    }

    System.out.println(driver.manage().logs());


    }
    catch(Exception E)

    {
        throw E; 

    }

Once click on Login, it goes to catch part and returns :

org.openqa.selenium.WebDriverException: The selendroid server on the device became unreachable.

How can I do successful login in app. and go inside app.

1

1 Answer 1

0

The error message

The selendroid server on the device became unreachable

suggests that the app under test has crashed, preventing Selendroid from continuing with the test.

Here are some steps you can take to resolve the issue:

  1. Check the logs of the app under test to see if there are any errors or exceptions.

  2. Try using a different version of Selendroid. The current version you're using may not be compatible with the app under test.

  3. Try using a different app that's similar in functionality to the one you're currently testing.

  4. Use a different automation tool that's better suited for your use case. There are many other mobile automation tools available, such as Appium, Robotium, etc.

  5. Check if there are any known issues with the app under test and try to resolve them.

You can also try these steps and see if it resolves the issue:

This error message often occurs due to a communication problem between the Selendroid server and the device. Here are a few possible solutions to resolve this issue:

  1. Try increasing the timeout values for implicit wait and driver:

    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

  2. Try setting the emulator flag to true, which means that you're using an emulator instead of a physical device:

    capa.setEmulator(true);

  3. If the issue still persists, try restarting the Selendroid server and the device and run the test again.

  4. If the issue still persists, try updating the Selendroid version to the latest available version.

  5. If the issue still persists, try using a different version of the Android operating system.

  6. You can also try accessing the log files of Selendroid and the device to see if they contain any error messages.

Here is a modified code sample that implements the solutions:

public class androidaut {
  public static void main(String[] args) throws Exception{
    try{
      SelendroidCapabilities capa = new SelendroidCapabilities("air.iNMyBabyPaid:1.3.0");
      capa.setSerial("192.168.xx.xx:xxxx");
      capa.setCapability("platformVersion", "17");
      capa.setEmulator(true);
      WebDriver driver = new SelendroidDriver(capa);
      driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
      WebElement username = driver.findElement(By.xpath("(//EditText)[1]"));
      username.click();
      username.sendKeys("tester");
      WebElement pass = driver.findElement(By.xpath("(//EditText)[2]"));
      driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
      pass.click();
      pass.sendKeys("stester#");
      WebElement login = driver.findElement(By.id("llSignIn"));
      if(login.isEnabled()) {
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        login.click();
      } else {
        System.out.println("Sorry! Your login button is disabled");
      }
      System.out.println(driver.manage().logs());
    } catch(Exception E) {
      throw E;
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.