我尝试使用Appium在真正的Android设备上测试应用程序。AndroidDriver实际上可以连接到应用程序,当我运行代码时,设备上的应用程序将被调用。但当我尝试使用driver.findElement
等函数时,没有任何React,等待了很长时间后,出现了Error communicating with the remote browser
。
下面是代码:
public class sampleTest {
private AndroidDriver driver;
@Before
public void setUp() throws MalformedURLException {
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("deviceName","Zachary");
desiredCapabilities.setCapability("udid","88Y5T19B1793");
desiredCapabilities.setCapability("platformName","Android");
desiredCapabilities.setCapability("platformVersion","3.0.0");
desiredCapabilities.setCapability("appPackage","com.test.test");
desiredCapabilities.setCapability("appActivity","host.exp.exponent.MainActivity");
URL remoteUrl = new URL("http://127.0.0.1:4723/wd/hub");
driver = new AndroidDriver(remoteUrl, desiredCapabilities);
//Here the app on device will be opened.
}
@Test
public void SampleTest() {
//Nothing happens here.
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
driver.findElement(By.id("SignIn")).click();
}
@After
public void tearDown() {
driver.quit();
}
}
等待很长时间后的错误信息:
org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
1条答案
按热度按时间mmvthczy1#
1.使用automationName功能并将其设置为UiAutomator2
如果问题仍然存在,请添加评论并提供新信息,我们将尝试解决问题。