有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

web元素在使用appium 安卓 app test的eclipse java中找不到该元素

这是我的密码。实际上,我是在用eclipse运行安卓应用程序和appium的。这里的应用程序已启动,但找不到任何元素,并在控制台中显示错误。错误是“线程“main”java.lang.NullPointerException中的异常

package amazon;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

//import junit.framework.Assert;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
//import org.junit.Assert;
//import org.junit.Test;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.安卓.AndroidDriver;

public class StartApplication {
    private static AndroidDriver driver;
    public static void main(String[] args) throws MalformedURLException, InterruptedException {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability("deviceName", "a71ce4a7");
        capabilities.setCapability("platformVersion", "5.0.2");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("appPackage", "com.hypersoft.vwallet");
        //capabilities.setCapability("appActivity", "com.hypersoft.vwallet.ui.activity.HomeActivityNew_");
        capabilities.setCapability("appActivity", "com.hypersoft.vwallet.ui.activity.SignInActivity_");
        driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
            driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
            //Thread.sleep(10000);
            System.out.println("App launched");
            //Thread.sleep(10000);
            driver.findElementById("com.hypersoft.vwallet:id/tvGetHelp").click();
            driver.findElement(By.id("com.hypersoft.vwallet:id/etMailAddress")).sendKeys("test@gmail.com");
            //driver.findElementByClassName("安卓.widget.EditText").sendKeys("test@gmail.com");;
            System.out.println("test");
            driver.findElement(By.id("com.hypersoft.vwallet:id/btnAgree")).click();
            driver.findElement(By.id("com.hypersoft.vwallet:id/etMailAddress")).sendKeys("test321@gmail.com");
            driver.findElement(By.id("com.hypersoft.vwallet:id/etPassword")).sendKeys("test4321");
            driver.findElement(By.id("com.hypersoft.vwallet:id/etPasswordRe")).sendKeys("test4321");
            driver.findElement(By.id("com.hypersoft.vwallet:id/etLastName")).sendKeys("Patel");
            driver.findElement(By.id("com.hypersoft.vwallet:id/etFirstName")).sendKeys("Niravpp");
            driver.hideKeyboard();
            driver.findElement(By.id("com.hypersoft.vwallet:id/btnSignUp")).click();
            driver.findElement(By.className("安卓.widget.ImageButton")).click();
            driver.findElementByName("Logout").click();
            driver.findElement(By.id("安卓:id/button1")).click();
            driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
            driver.findElement(By.id("com.hypersoft.vwallet:id/etMailAddress")).sendKeys("test321@gmail.com");
            driver.findElement(By.id("com.hypersoft.vwallet:id/etPassword")).sendKeys("test4321");
            driver.findElement(By.id("com.hypersoft.vwallet:id/btnSignIn")).click();
            WebElement element = driver.findElement(By.name("VCA Wallet"));
            String strng = element.getText();
            Assert.assertEquals(strng,"VCA Wallet");

            if(strng.equals("VCA Wallet"))
            {
             System.out.printf("pass\n");
            } else {
                System.out.println("Fail\n");
            }
            System.out.println(strng);
            //driver.swipe(startx, starty, endx, endy, duration);

            driver.close();         
}
}

I will add my console in bellow screen shoot so, please check it and give some suggestion.


共 (0) 个答案