无法在ubuntu中为Eclipse中的Android项目运行appium
这是我的java类,我尝试在ubuntu中使用控制台运行Appium,但由于所需的功能,它无法创建新的远程会话查看屏幕截图无法在ubuntu中为Eclipse中的Android项目运行appium,android,automated-tests,appium,Android,Automated Tests,Appium,这是我的java类,我尝试在ubuntu中使用控制台运行Appium,但由于所需的功能,它无法创建新的远程会话查看屏幕截图 import java.net.MalformedURLException; import java.net.URL; import java.util.concurrent.TimeUnit; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; imp
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();
}
}
这是我放在控制台中由npm运行Appium的代码。我正在使用最新版本的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 org.testng.reporters.EmailableReporter2@47f37ef1: 6 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 2 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@7907ec20: 8 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@6ea6d14e: 15 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@4563e9ab: 3 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@d7b1517: 3 ms
,您正在使用的构造函数,应该是要测试的端点的远程ip
public RemoteWebDriver(URL remoteAddress ...
能否尝试将您的0.0.0.0 uri更改为要测试的设备的有效IP/主机
编辑
如果这不是问题所在,我看到了错误
位于org.openqa.selenium.remote.ProtocolHandshake.createSessionProtocolHandshake.java:91
协议握手让我觉得您的服务器可能也在侦听https请求,而您正试图通过http建立连接
尝试将uri从http更改为https。问题出在.apk文件本身!我已经更改了另一个文件,它工作正常仍然不工作:“org.openqa.selenium.remote.ProtocolHandshake createSession INFO:正在尝试双方言会话,假设Postel定律在远程端适用失败配置:@BeforeClass setUp org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败。系统信息:host:'tarek-Vostro-3902',ip:'127.0.1.1',os.name:'Linux',Driver info:Driver.version:RemoteWebDriver'如果仍然无效,是否可以尝试将-vv添加到appium执行行的末尾以获得更详细的调试输出?仍然不工作,-vv仅打印appium的版本,然后它就会断开并出现以下错误:`无法创建新的远程会话。所需功能=功能[{appPackage=com.推土机.gaa,appActivity=com.推土机.gaa.activities.MainActivity,platformName=Android,udid=*************,deviceName=SM-G360H,version=4.4.4}],所需功能=功能[{}]`