用 appium 写了一个很简单的点击动作,代码如下

package com.test;  

import io.appium.java_client.AppiumDriver;  
import org.junit.After;  
import org.junit.Before;  
import org.junit.Test;  
import org.openqa.selenium.By;  
import org.openqa.selenium.WebElement;  
import org.openqa.selenium.remote.CapabilityType;  
import org.openqa.selenium.remote.DesiredCapabilities;  

import java.io.File;  
import java.net.URL;  
import java.util.List;  

public class appium {  
    private AppiumDriver driver;  

    @Before  
    public void setUp() throws Exception {  
       // set up appium  
        DesiredCapabilities capabilities = new DesiredCapabilities();  
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");  
        capabilities.setCapability("platformName", "Android");  
        capabilities.setCapability("deviceName","9DS8FYGAJFPRQW7T");  
        capabilities.setCapability("platformVersion", "6.0");  

        capabilities.setCapability("appPackage", "com.greenpoint.android.mc10086.activity");  
        capabilities.setCapability("appActivity", "com.leadeon.cmcc.base.StartPageActivity");  
        driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);  
    }  

    @After  
    public void tearDown() throws Exception {  
        driver.quit();  
    }  

    @Test  
    public void addContact(){  

        driver.findElementByName("我的").click();  
    }  
} 


代码没有错误,但点击 runas-J-unit 出错,弹出出错框如下:


求解答


↙↙↙阅读原文可查看相关链接,并与作者交流