我对编程非常陌生。我的主要目标是编写登录到 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 中,它用红色下划线标出,并表示无法解决。我不确定如何解决此问题。
这些是我得到的选择:
答案 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");
}
}
尝试更新代码