无法运行在设备上我的code [英] Unable to Run my code on device

查看:235
本文介绍了无法运行在设备上我的code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 包的Andr​​oid;进口java.net.MalformedURLException;
进口的java.net.URL;
进口java.util.concurrent.TimeUnit中;进口org.openqa.selenium.By;
进口org.openqa.selenium.WebDriver;
进口org.openqa.selenium.remote.CapabilityType;
进口org.openqa.selenium.remote.DesiredCapabilities;
进口org.openqa.selenium.remote.RemoteWebDriver;
进口org.testng.annotations.BeforeTest;
进口org.testng.annotations.Test;公共类SimpleAndroidCalcTest {    驱动程序的webdriver;
    @BeforeTest
    公共无效设置()抛出MalformedURLException的{
        // DesiredCapabilities类创建的对象。
        DesiredCapabilities能力=新DesiredCapabilities();
        capabilities.setCapability(设备名称,0227074902999561);
        capabilities.setCapability(CapabilityType.BROWSER_NAME,机器人);
        capabilities.setCapability(CapabilityType.VERSION5.1.1);
        capabilities.setCapability(platformName,Android的);
        capabilities.setCapability(appPackage,com.example.mypackage);
        capabilities.setCapability(appActivity,com.example.mypackage.MainActivity);
        司机=新RemoteWebDriver(新URL(http://127.0.0.1:4723/wd/hub),能力);
        driver.manage()超时()implicitlyWait(15 TimeUnit.SECONDS)。
    }    @测试公共无效SKIP()
    {
        driver.findElement(By.xpath(// android.widget.Button [@文本='SKIP']))点击()。
    }
}

这是以下控制台错误,我不能够运行上面的code上的设备。我运行Ubuntu 14.04 LTS的机器上,这些code。 Eclipse版本火星控制台错误显示为配置失败。@BeforeTest的setUp
    org.openqa.selenium.SessionNotCreatedException:一个新的会话无法建立。 (原来的错误:命令失败:/ bin / sh的-c的/ usr / bin中/亚行亚洲开发银行-s服务器是过时的杀戮......等待换设备。
    ADB服务器没有ACK
    *无法启动服务器*

  ****控制台错误:****[TestNG的]运行:
  /tmp/testng-eclipse-1773582615/testng-customsuite.xml配置失败:@BeforeTest的setUp
org.openqa.selenium.SessionNotCreatedException:一个新的会话无法建立。 (原来的错误:命令失败:/ bin / sh的-c的/ usr / bin中/亚行亚洲开发银行-s服务器是过时的杀戮......等待换设备。
ADB服务器没有ACK
*无法启动服务器*
)(警告:服务器未提供任何信息的堆栈跟踪)
命令持续时间或超时:14.00秒
构建信息:版本:2.48.2,修订版:'41bccdd,时间:2015年10月9日19点55分52秒
系统信息:主持人:rishabhambre联想-B50-70',IP:127.0.1.1,os.name:'Linux的,os.arch:AMD64,os.version:3.19.0-25-通用',java.version:1.8.0_66
驱动方式:org.openqa.selenium.remote.RemoteWebDriver
    在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)
    在sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    在java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    在org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
    在org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
    在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
    在org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
    在org.openqa.selenium.remote.RemoteWebDriver<&初始化GT;(RemoteWebDriver.java:129)
    在org.openqa.selenium.remote.RemoteWebDriver<&初始化GT;(RemoteWebDriver.java:156)
    在android.SimpleAndroidCalcTest.setUp(SimpleAndroidCalcTest.java:29)
    在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)
    在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    在java.lang.reflect.Method.invoke(Method.java:497)
    在org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
    在org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:514)
    在org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215)
    在org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
    在org.testng.TestRunner.beforeRun(TestRunner.java:656)
    在org.testng.TestRunner.run(TestRunner.java:624)
    在org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
    在org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
    在org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
    在org.testng.SuiteRunner.run(SuiteRunner.java:268)
    在org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    在org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    在org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
    在org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
    在org.testng.TestNG.run(TestNG.java:1064)
    在org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:113)
    在org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:206)
    在org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:177)SKIPPED:SKIP===============================================
    默认测试
    测试运行:1,失败:0,跳过:1
    配置故障:1,跳过:0
===============================================
===============================================
默认套房
总的测试运行:1,失败:0,跳过:1
配置故障:1,跳过:0
===============================================[TestNG的]采取org.testng.reporters.JUnitReportReporter@2a098129时间:15毫秒
[TestNG的]采取org.testng.reporters.EmailableReporter2@16b4a017时间:5毫秒
[TestNG的]采取org.testng.reporters.jq.Main@68f7aae2时间:17毫秒
[TestNG的]采取org.testng.reporters.SuiteHTMLReporter@2f410acf时间:7毫秒
[TestNG的]采取org.testng.reporters.XMLReporter@1996cd68时间:6毫秒    [TestNG的]时间采取[FailedReporter通过= 0失败= 0跳过= 0]:2毫秒


解决方案

有可能是亚行的二进制文件副本系统中的

首先删除所有亚行的二进制文件

  sudo易于得到净化--auto-删除Android的工具-ADB

然后下载最新版本的Andr​​oid SDK中平台工具,并尝试再次运行脚本。

请确保您设置Android SDK中家庭环境中的路径

package android;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class SimpleAndroidCalcTest {

    WebDriver driver;
    @BeforeTest
    public void setUp() throws MalformedURLException{
        // Created object of DesiredCapabilities class.
        DesiredCapabilities capabilities = new DesiredCapabilities(); 
        capabilities.setCapability("deviceName", "0227074902999561");
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");         
        capabilities.setCapability(CapabilityType.VERSION, "5.1.1");        
        capabilities.setCapability("platformName", "Android");  
        capabilities.setCapability("appPackage", "com.example.mypackage"); 
        capabilities.setCapability("appActivity", "com.example.mypackage.MainActivity"); 
        driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);        
    }

    @Test public void SKIP() 
    {   
        driver.findElement(By.xpath("//android.widget.Button[@text='SKIP']")).click();
    }
}

This is the following console error, and I am not able to Run the above code on device. I am running these code on Ubuntu 14.04 LTS machine. Eclipse version Mars.Console error is shown as FAILED CONFIGURATION: @BeforeTest setUp org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Command failed: /bin/sh -c "/usr/bin/adb" -s adb server is out of date. killing... wait-for-device ADB server didn't ACK * could not start server *

****Console Error:****    

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

FAILED CONFIGURATION: @BeforeTest setUp
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Command failed: /bin/sh -c "/usr/bin/adb" -s adb server is out of date.  killing... wait-for-device
ADB server didn't ACK
* could not start server *
) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 14.00 seconds
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
System info: host: 'rishabhambre-Lenovo-B50-70', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-25-generic', java.version: '1.8.0_66'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:156)
    at android.SimpleAndroidCalcTest.setUp(SimpleAndroidCalcTest.java:29)
    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:497)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:514)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
    at org.testng.TestRunner.beforeRun(TestRunner.java:656)
    at org.testng.TestRunner.run(TestRunner.java:624)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
    at org.testng.SuiteRunner.run(SuiteRunner.java:268)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
    at org.testng.TestNG.run(TestNG.java:1064)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:113)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:206)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:177)

SKIPPED: SKIP

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


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

[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@2a098129: 15 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@16b4a017: 5 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@68f7aae2: 17 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@2f410acf: 7 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@1996cd68: 6 ms

    [TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 2 ms

解决方案

There may be duplicates of adb binaries in your system

First remove all adb binaries

sudo apt-get purge --auto-remove android-tools-adb

Then download latest version of android sdk platform tools and try running your script again..

Make sure you set android sdk home in your environment path

这篇关于无法运行在设备上我的code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆