TA的每日心情 无聊 昨天 09:47
签到天数: 528 天
连续签到: 1 天
[LV.9]测试副司令
1 测试积点
public static void main(String[] args) throws MalformedURLException {
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.BROWSER_NAME, "");
cap.setCapability("platformName", "Android"); //指定测试平台
cap.setCapability("deviceName", "127.0.0.1:62001"); //指定测试机的ID,通过adb命令`adb devices`获取
cap.setCapability("platformVersion", "7.1.2");
//将上面获取到的包名和Activity名设置为值
cap.setCapability("appPackage", "com.sky.jisuanji");//App安装后的包名,注意与原来的CalcTest.apk不一样
cap.setCapability("appActivity", ".JisuanjizixieActivity");//app测试人员常常要获取activity,进行相关测试,后续会讲到
//A new session could not be created的解决方法
cap.setCapability("appWaitActivity","JisuanjizixieActivity");
//每次启动时覆盖session,否则第二次后运行会报错不能新建session
cap.setCapability("sessionOverride", true);
AppiumDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
driver.findElementById("com.meizu.flyme.calculator:id/digit1").click();
driver.findElementById("com.meizu.flyme.calculator:id/plus").click();
driver.findElementById("com.meizu.flyme.calculator:id/digit2").click();
driver.findElementById("com.meizu.flyme.calculator:id/eq").click();
}
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.9.0', revision: '698b3178f0', time: '2018-02-05T14:56:13.134Z'
System info: host: 'SKY-20200711AWF', ip: '192.168.0.101', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111'
Driver info: driver.version: AndroidDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:622)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:109)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:39)
at appium_demo.Calc_demo.main(Calc_demo.java:29)
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:170)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at okio.Okio$2.read(Okio.java:139)
at okio.AsyncTimeout$2.read(AsyncTimeout.java:237)
at okio.RealBufferedSource.indexOf(RealBufferedSource.java:345)
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:217)
at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:212)
at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
at okhttp3.RealCall.execute(RealCall.java:77)
at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:97)
at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:47)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:101)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:138)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
... 7 more 复制代码 这个错误的解决方案是什么?
我来回答