2017-01-23 99 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 ..請參閱我的編輯? –