2 回答
TA贡献1824条经验 获得超6个赞
您需要像这样使用现有的构造函数:
https://appium.github.io/java-client/io/appium/java_client/android/AndroidDriver.html
你需要使用java.net.URL
而不是com.gargoylesoftware.htmlunit.javascript.host.URL
TA贡献1803条经验 获得超3个赞
1. 首先,请您仔细检查进口商品好吗?与正确的分享下面的代码片段
package tests.web;
import java.net.MalformedURLException;
import java.net.URL;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileBrowserType;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
public class AndroidWebTest {
private static final String ACCESS_KEY = System.getenv(“SEETEST_IO_ACCESS_KEY”);
private static final String CLOUD_URL = “https://cloud.seetest.io:443/wd/hub”;
private static final String TITLE = “Testing Website on Android Chrome with Java”;
private AndroidDriver driver = null;
@Before
public void setUp() throws MalformedURLException {
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(“testName”, TITLE);
dc.setCapability(“accessKey”, ACCESS_KEY);
dc.setBrowserName(MobileBrowserType.CHROME);
driver = new AndroidDriver(new URL(CLOUD_URL), dc);
}
@Test
public void testAppiumOnChrome() {
driver.get(“https://amazon.com”);
System.out.println(driver.getTitle());
if (driver.getCapabilities().getCapability(“device.category”).equals(“TABLET”)) {
driver.findElement(By.xpath(“//*[@name=’field-keywords’]”)).sendKeys(“iPhone”);
driver.findElement(By.xpath(“//*[@text=’Go’]”)).click();
} else {
driver.findElement(By.xpath(“//*[@name=’k’]”)).sendKeys(“iPhone”);
driver.findElement(By.xpath(“//*[@value=’Go’]”)).click();
}
}
@After
public void tearDown() {
if (driver != null) {
driver.quit();
}
}
}
有关更多详细信息,请参阅比较和组合 Web 和移动测试自动化驱动程序一文。
如果您的项目是基于 maven 的,您能否也仔细检查依赖项?例如,请在此处查看最新的 appium 更新
适当的 maven repo 来检查(最新的)java 客户端: https ://mvnrepository.com/artifact/io.appium/java-client
添加回答
举报