2015-06-16 4 views
0

Я новичок в selendroid, и я получаю следующую ошибку при выполнении следующего сценария. Я работаю над selendroid для родного приложения.Ошибка при общении с сервером selendroid на устройстве:

Было бы здорово, если бы кто-нибудь помог мне решить эту проблему!

Ниже мой сценарий

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(); 
} 

} 

Я также создал 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; 
    } 

} 

я получаю следующее сообщение об ошибке:

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 
+0

Пожалуйста, разместите ПОЛНУЮ стеклянную корзину. –

ответ

0

Вы не инициализации сервера до тест начинает работать введите следующий код в @BeforeMethod аннотированный метод

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");