Error occured while communicating with selendroid server on the device:

214 views Asked by At

I am new in selendroid and i am getting following error when executed following script. I am working on selendroid for native app.

It would be great if any one help me to solve this!

Following is my script

package com.peddlebuyer.test;

import java.net.URL;
import io.selendroid.SelendroidCapabilities;
import io.selendroid.SelendroidConfiguration;
import io.selendroid.SelendroidDriver;
import io.selendroid.SelendroidLauncher;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.Response;
import org.testng.Assert;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.touch.FlickAction;
import org.openqa.selenium.interactions.touch.TouchActions;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
import java.util.concurrent.TimeUnit;
import java.util.logging.ConsoleHandler;

import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import io.selendroid.waiter.TestWaiter;
import io.selendroid.waiter.WaitingConditions;

public class PeddleBuyer {
private WebDriver driver = null;

@BeforeMethod
public void beforeMethod() throws Exception {

}

@Test
public void assertSellerCanLogin() {
UserDO user = new UserDO("[email protected]","123456");
try {
        loginUser(user);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
 }

 private void loginUser(UserDO user) throws Exception 
   {

     SelendroidCapabilities capa = new                  SelendroidCapabilities("com.peddle.buyer:1.31");
     driver = new SelendroidDriver(capa);
     capa.setCapability("app-activity", "com.peddle.buyer.SplashActivity");
     capa.setCapability("app-wait-activity", "com.peddle.buyer.BuyerHomeActivity");


    driver.get("and-activity://com.peddle.buyer.BuyerHomeActivity");

    WebDriverWait wait = new WebDriverWait(driver, 60);
    wait.until(ExpectedConditions.presenceOfElementLocated(By.id("onBoardTopContainer")));    
    WebElement pages1 = driver.findElement(By.id("com.peddle.buyer:id/onBoardTopContainer"));
    TouchActions flick1 = new TouchActions(driver).flick(pages1, -100, 0, 0);
    flick1.perform();

    WebElement pages2 = driver.findElement(By.id("com.peddle.buyer:id/onBoardTopContainer"));
    TouchActions flick2 = new TouchActions(driver).flick(pages2, -100, 0, 0);
    flick2.perform();

    WebElement pages3 =   driver.findElement(By.id("com.peddle.buyer:id/onBoardTopContainer"));
    TouchActions flick3 = new TouchActions(driver).flick(pages3, -100, 0, 0);
    flick3.perform();

    driver.findElement(By.linkText("Get started")).click();
    driver.findElement(By.linkText("Log in with Peddle")).click();

    WebElement Email = driver.findElement(By.id("emailInputTextView"));
    Email.sendKeys(user.email);

    driver.findElement(By.id("passwordInput")).sendKeys(user.password);

    driver.findElement(By.linkText("Log in")).click();


    //WebDriverWait wait = new WebDriverWait(driver, 60);
    //wait.until(ExpectedConditions.presenceOfElementLocated(By.id("taskIdText")));
   // wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText("Buy")));
   // wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText("Pass")));
    //wait.until(ExpectedConditions.presenceOfElementLocated(By.id("taskThumbImage")));
   // wait.until(ExpectedConditions.presenceOfElementLocated(By.id("infoButton")));
   // wait.until(ExpectedConditions.presenceOfElementLocated(By.id("footerShadowLayout")));

    capa.setCapability("app-activity", "com.peddle.buyer.BuyerHomeActivity");
    capa.setCapability("app-wait-activity", "com.peddle.buyer.TaskInformationActivity");
    driver.get("and-activity://com.peddle.buyer.TaskInformationActivity");



}

@AfterMethod
public void afterMethod() {

    //driver.quit();
 }

}

I have also created UserDO.java

package com.peddlebuyer.test;

 public class UserDO {

 public String email;
 public String password;

 public UserDO(String email, String password) {
        super();
        this.email = email;
        this.password = password;
   }

 }

I am getting following error:

E/AndroidRuntime( 1190): FATAL EXCEPTION: main
E/AndroidRuntime( 1190): java.lang.RuntimeException: Unable to start        activity Co
mponentInfo{com.peddle.buyer/com.peddle.buyer.TaskInformationActivity}:   java.lang.NullPointerException
1

There are 1 answers

0
Sandeep Singh On

You are not initializing the server before the test is starting to run put the following code in your @BeforeMethod annotated method

SelendroidCapabilities capa = new SelendroidCapabilities("com.peddle.buyer:1.31");
driver = new SelendroidDriver(capa);
capa.setCapability("app-activity", "com.peddle.buyer.SplashActivity");
capa.setCapability("app-wait-activity", "com.peddle.buyer.BuyerHomeActivity");