【发布时间】:2015-08-12 02:33:34
【问题描述】:
当我尝试运行我的代码时:
import static org.junit.Assert.*;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;
public class desiredcapab {
@Test
public void test() throws MalformedURLException {
File appDir =new File("src");
File app = new File(appDir, "Piano Tiles 1_7.apk");
DesiredCapabilities cap=new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Android_Emulator");
cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
AndroidDriver driver =new AndroidDriver(new URL("https://127.0.0.1:4723/wd/hub"),cap);
}
}
作为 JUNIT 测试,我收到以下错误:
org.openqa.selenium.remote.UnreachableBrowserException: 不能 开始一个新的会话。可能的原因是远程地址无效 服务器或浏览器启动失败。构建信息:版本:'2.47.1', 修订:'411b314',时间:'2015-07-30 02:56:46' 系统信息:主机: 'FUEL091', ip: '172.17.64.88', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_51' 驱动信息: driver.version:AndroidDriver 在 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:589) 在 io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180) 在 org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242) 在 org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:128) 在 org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:155) 在 io.appium.java_client.AppiumDriver.(AppiumDriver.java:109) 在 io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:39) 在desiredcapab.test(desiredcapab.java:30) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)在 java.lang.reflect.Method.invoke(未知来源)在 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) 在 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 在 org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 在 org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) 在 org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) 在 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) 在 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) 在 org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 在 org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 在 org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 在 org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 在 org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 在 org.junit.runners.ParentRunner.run(ParentRunner.java:363) 在 org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) 在 org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) 引起:javax.net.ssl.SSLHandshakeException:远程主机关闭 握手期间的连接 sun.security.ssl.SSLSocketImpl.readRecord(未知来源)在 sun.security.ssl.SSLSocketImpl.performInitialHandshake(未知来源) 在 sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) at sun.security.ssl.SSLSocketImpl.startHandshake(未知来源)在 org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394) 在 org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353) 在 org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134) 在 org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353) 在 org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380) 在 org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) 在 org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184) 在 org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88) 在 org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) 在 org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) 在 org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71) 在 org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55) 在 org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:143) 在 org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:89) 在 org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:134) 在 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:568) ... 30 更多原因:java.io.EOFException: SSL peer 关闭 错误地位于 sun.security.ssl.InputRecord.read(Unknown Source) ... 还有 50 个
【问题讨论】:
-
好吧,所以我想通了,我花了几分钟来调试它。将 URL 提供给驱动程序时将 HTTPS:// 更改为 HTTP。
标签: junit