我的Java程序中的“驱动程序无法解析”

时间:2019-02-21 01:25:16

标签: java android selenium appium helper

我对编程非常陌生。我的主要目标是编写登录到 android 应用程序中的代码,并完成您用手指要做的所有事情。到目前为止,我只能打开该应用程序,现在我只能输入登录信息。

我不熟悉与Java,Eclipse,Appium和Selenium有关的每个方面。

这是我的代码:

package OpenOfferUpTest;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
import io.appium.java_client.android.AndroidDriver;

public class OpenOfferUp {


@Test
public void OpensOfferUp() throws MalformedURLException
{
File OfferUp = new File("C:\\Users\\boung\\Desktop\\OfferUp.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("deviceName", "Virtual Device");
cap.setCapability("platformName", "android");
cap.setCapability("null", "OfferUp");
cap.setCapability("appPackage", "com.offerup");
cap.setCapability("appActivity", "com.offerup.android.login.splash.LoginSplashActivity");

AndroidDriver driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), cap);

}
@Test
public void SimpleTest() {

    driver.findElement(By.id("email_button")).sendKeys("sourgta@gmail.com");

}



}     

driver 中,它用红色下划线标出,并表示无法解决。我不确定如何解决此问题。

这些是我得到的选择:

I am not allowed to add pictures yet, so please bare with me.

1 个答案:

答案 0 :(得分:0)

package OpenOfferUpTest;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
import org.testng.annotations.*;
import io.appium.java_client.android.AndroidDriver;

public class OpenOfferUp {

AndroidDriver driver;

@BeforeTest
public void OpensOfferUp() throws MalformedURLException
{
File OfferUp = new File("C:\\Users\\boung\\Desktop\\OfferUp.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("deviceName", "Virtual Device");
cap.setCapability("platformName", "android");
cap.setCapability("null", "OfferUp");
cap.setCapability("appPackage", "com.offerup");
cap.setCapability("appActivity", "com.offerup.android.login.splash.LoginSplashActivity");

driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), cap);

}
@Test
public void SimpleTest() {

    driver.findElement(By.id("email_button")).sendKeys("sourgta@gmail.com");

}

}   

尝试更新代码