I am a beginner of Appium and Java. When I perform my first demo for Android test, I just get 2 errors and have no idea how to fix them after google. So I have to find some help here. Code:
import java.net.MalformedURLException;
import java.net.URL;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
public class AutoTest {
private AndroidDriver<WebElement> driver;
@Before
public void Setup() throws MalformedURLException{
//File classPathRoot = new java.io.File(System.getProperty("user.dir"));
//File appDir = new File(classPathRoot,"app/login.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "emulator-5554");
capabilities.setBrowserName("Android");
capabilities.setCapability(CapabilityType.VERSION, "6.0.1");
capabilities.setPlatform(Platform.ANDROID);
//capabilities.setCapability("app", appDir.getAbsolutePath());
capabilities.setCapability("appPackage", "com.study.kukaka.login");
capabilities.setCapability("appActivity", "LoginActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723"),capabilities);
}
@Test
public void test() {
driver.findElement(By.id("email")).sendKeys("myemail@hotmail.com");
driver.findElement(By.id("password")).sendKeys("whatever");
driver.findElement(By.id("email_sign_in_button")).click();
System.out.println("Test pass!");
}
@After
public void End(){
driver.quit();
}
}
And the errors:
The library I used is as below. Library I used
Any help is appreciated!
You may need to selenium remote driver jar file to build path. ( I could not seen it your build path ) Download from maven http://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-remote-driver/2.44.0 and put it to your build path. If not works again, putting error logs will be more heplfull.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.