【发布时间】:2017-12-07 14:51:05
【问题描述】:
我正在尝试使用带有 Java 的 Appium 和 Cucumber 自动化一个 android 应用程序。我已经编写了一个功能的代码,它工作正常。但有时在运行脚本时会抛出错误
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original err
or: Could not proxy command to remote server. Original error: Error: read ECONNRESET (WARNING: The server did not provid
e any stacktrace information)
源代码:
import com.google.common.base.Function;
import com.intel.truevr.appautomation.core.Capabilities;
import org.openqa.selenium.By;
import io.appium.java_client.MobileDriver;
import io.appium.java_client.MobileElement;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import org.openqa.selenium.support.ui.Wait;
import java.util.List;
import io.appium.java_client.TouchAction;
public class C754L2D {
Capabilities c = new Capabilities();
MobileDriver driver = c.getDefaultCapabilities();
Wait wait = new Wait() {
@Override
public Object until(Function isTrue) {
return null;
}
};
@Given("^User taps the toggle button in the live 2D video playing screen$")
public void user_taps_toggle_button() throws Exception {
MobileElement allow = (MobileElement) driver.findElement(By.id("com.android.packageinstaller:id/permission_allow_button"));
allow.click();
List<MobileElement> list = driver.findElements(By.id("android:id/text1"));
for(MobileElement ele :list) {
String text = ele.getText();
if(text.equals("Live")){
ele.click();
break;
}
}
MobileElement panoramicButton = (MobileElement) driver.findElement(By.id("com.jackalopelite.simplecontainer:id/rl_select_2d"));
panoramicButton.click();
MobileElement Screen= (MobileElement) driver.findElement(By.className("android.view.View"));
TouchAction ta = new TouchAction(driver);
ta.tap(Screen, 531, 357).perform();
MobileElement toggleButton = (MobileElement) driver.findElement(By.id("com.jackalopelite.simplecontainer:id/fab_player_switch_mode"));
toggleButton.click();
}
@When("^Taps back button in the transition screen$")
public void taps_back_button() throws InterruptedException {
Thread.sleep(1000);
MobileElement backButton = (MobileElement) driver.findElement(By.id("com.jackalopelite.simplecontainer:id/iv_cardboard_back"));
backButton.click();
}
@Then("^The transition screen should dismiss and user should be navigated back to 2d live video playing screen$")
public void dismiss_transition_screen() {
try{
MobileElement cameraAngleSelectionButton = (MobileElement) driver.findElement(By.id("com.jackalopelite.simplecontainer:id/rl_player_switch_camera_parent"));
if(cameraAngleSelectionButton != null) {
System.out.println("The transition screen is dismissed and user is navigated back to 2d live video playing screen");
}
}catch(Exception e){
System.out.println("The transition screen is not dismissed and user is not navigated back to 2d live video playing screen");
}
//driver.quit();
}
}
当我关闭模拟器并再次打开它时,此错误被清除并且脚本工作正常。有人可以帮我吗?
【问题讨论】:
-
阅读此github thread,与同一问题有关。
-
该线程中没有解决方案