2017-01-23 73 views
0

的Android项目这是我的Java类,我试图在Ubuntu的控制台运行Appium但由于与期望的能力(查看截图)无法运行在Ubuntu appium在Eclipse中

无法创建新的远程会话
import java.net.MalformedURLException; 
import java.net.URL; 
import java.util.concurrent.TimeUnit; 


import org.testng.annotations.AfterClass; 
import org.testng.annotations.BeforeClass; 
import org.testng.annotations.Test; 
import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.remote.DesiredCapabilities; 
import org.openqa.selenium.remote.RemoteWebDriver; 


public class FirstTest { 

    WebDriver driver; 

    @BeforeClass 
    public void setUp() throws MalformedURLException{ 
     DesiredCapabilities capabilities = new DesiredCapabilities(); 
     capabilities.setCapability("deviceName", "SM-G360H");  
     capabilities.setCapability("version", "4.4.4"); 
     capabilities.setCapability("platformName", "Android"); 
     capabilities.setCapability("platformVersion", "platform"); 
     capabilities.setCapability("udid", "************"); 
     capabilities.setCapability("appPackage", "com.bulldozer.gaa"); 
     capabilities.setCapability("appActivity", "com.bulldozer.gaa.activities.MainActivity"); 
     driver = new RemoteWebDriver(new URL("http://0.0.0.0:4723/wd/hub"),capabilities); 
     driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); 
    } 

    @Test 
    public void Test1() throws InterruptedException { 

     //driver.wait(10000); 
     System.out.println("GAA"); 
     driver.findElement(By.id("acceptCheckbox")).click(); 
     driver.findElement(By.id("continueBtn")).click(); 

    } 

    @AfterClass 
    public void tearDown() { 
     driver.quit(); 

    } 

} 

这是我放在控制台运行Appium npm的代码。我正在使用Appium 1.6.3版本(最新版本)。

appium --default-capabilities '{"app":"gaa","appium-version":"1.6.3","platformName":"Android","deviceName":"SM-G360H","nativeInstrumentsLib":true}' --command-timeout "0" --pre-launch 





    [TestNG] Running: 
    /tmp/testng-eclipse-1594673304/testng-customsuite.xml 

Jan 23, 2017 5:55:43 PM org.openqa.selenium.remote.ProtocolHandshake createSession 
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end 
Jan 23, 2017 5:55:43 PM org.openqa.selenium.remote.ProtocolHandshake createSession 
INFO: Falling back to original OSS JSON Wire Protocol. 
Jan 23, 2017 5:55:43 PM org.openqa.selenium.remote.ProtocolHandshake createSession 
INFO: Falling back to straight W3C remote end connection 
FAILED CONFIGURATION: @BeforeClass setUp 
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{appPackage=com.bulldozer.gaa, appActivity=com.bulldozer.gaa.activities.MainActivity, udid=************}], required capabilities = Capabilities [{}] 
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700' 
System info: host: 'tarek-Vostro-3902', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-59-generic', java.version: '1.8.0_91' 
Driver info: driver.version: RemoteWebDriver 
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91) 
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) 
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241) 
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128) 
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155) 
    at FirstTest.setUp(FirstTest.java:30) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85) 
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:517) 
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213) 
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:140) 
    at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:170) 
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:104) 
    at org.testng.TestRunner.privateRun(TestRunner.java:771) 
    at org.testng.TestRunner.run(TestRunner.java:621) 
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:357) 
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352) 
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310) 
    at org.testng.SuiteRunner.run(SuiteRunner.java:259) 
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) 
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) 
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1199) 
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1124) 
    at org.testng.TestNG.run(TestNG.java:1032) 
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132) 
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236) 
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81) 

SKIPPED CONFIGURATION: @AfterClass tearDown 
SKIPPED: Test1 

=============================================== 
    Default test 
    Tests run: 1, Failures: 0, Skips: 1 
    Configuration Failures: 1, Skips: 1 
=============================================== 


=============================================== 
Default suite 
Total tests run: 1, Failures: 0, Skips: 1 
Configuration Failures: 1, Skips: 1 
=============================================== 

[TestNG] Time taken by [email protected]: 6 ms 
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 2 ms 
[TestNG] Time taken by [email protected]: 8 ms 
[TestNG] Time taken by [email protected]: 15 ms 
[TestNG] Time taken by [email protected]: 3 ms 
[TestNG] Time taken by [email protected]: 3 ms 

This is the error i got :

回答

0

问题来自.apk文件本身!我已经改变了另一个文件它工作正常

1

According to source,您正在使用的构造函数,应该是远程 IP端点进行测试的。

public RemoteWebDriver(URL remoteAddress ... 

你能试着改变你的0.0.0.0 URI为有效的IP /主机的设备进行测试的?

编辑

如果这不是问题,我看到的错误

at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)

协议握手让我觉得,你的服务器还可以听HTTPS请求,而你试图通过http建立连接?

尝试将您的uri从http更改为https

+0

好的,我会尽量改变这个!感谢您的想法 – Emna

+0

仍然没有工作: “org.openqa.selenium.remote.ProtocolHandshake了createSession 信息:试图双向方言会话,假设Postel的法律持有远端 配置失败真:@BeforeClass的setUp org.openqa。 selenium.remote.UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器的地址无效或浏览器启动失败。 系统信息:host:'tarek-Vostro-3902',ip:'127.0.1.1',os.name:'Linux', 驱动程序信息:driver.version:RemoteWebDriver' – Emna

+0

hmm ..请参阅我的编辑? –