Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通过Appium在Android操作系统上运行Selenium测试_Java_Android_Selenium_Selenium Webdriver_Appium - Fatal编程技术网

Java 通过Appium在Android操作系统上运行Selenium测试

Java 通过Appium在Android操作系统上运行Selenium测试,java,android,selenium,selenium-webdriver,appium,Java,Android,Selenium,Selenium Webdriver,Appium,我正在尝试在android emulator上运行selenium测试,但无法正常工作。我使用eclipse用java编写代码,设置如下 1.selenium服务器独立jar.2.44.0 2.testng-6.8.jar 3.附录1.3.4.1 这些就是我发送给Appium的功能 @BeforeMethod() public void setUp() throws Exception { //Appium needs the path of app build //Set u

我正在尝试在android emulator上运行selenium测试,但无法正常工作。我使用eclipse用java编写代码,设置如下 1.selenium服务器独立jar.2.44.0 2.testng-6.8.jar 3.附录1.3.4.1 这些就是我发送给Appium的功能

@BeforeMethod()
public void setUp() throws Exception {

    //Appium needs the path of app build
    //Set up the desired capabilities and pass the iOS SDK version and app path to Appium
    DesiredCapabilities capabilities = new DesiredCapabilities();

    File appDir = new File("C:/Appium");
    File app = new File(appDir, "android-server-2.38.0.apk");        
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("automationName", "Appium");       
    capabilities.setCapability("deviceName", "Nexus_5");
    capabilities.setCapability("browserName", "Firefox");

    driver = new SelendroidDriver(new URL("http://localhost:4723/wd/hub"), capabilities);
这是我通常从Eclipse获得的输出

FAILED CONFIGURATION: @AfterMethod tearDown
org.openqa.selenium.WebDriverException: Not yet implemented. Please help us: http://appium.io/get-involved.html (WARNING: The server did not provide any stacktrace information)

这是我通常从Appium获得的输出

> Starting Node Server
> info: Welcome to Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe)
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: [debug] Non-default server args: {"app":"C:\\Appium\\android-server-2.38.0.apk","address":"127.0.0.1","fullReset":true,"logNoColors":true,"androidPackage":"org.openqa.selenium.android.app","androidActivity":".MainActivity","avd":"N5-Emulator","deviceName":"Nexus_5","platformName":"Android","platformVersion":"19","automationName":"Appium"}
> info: Console LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"automationName":"Appium","platformName":"Android","deviceName":"Nexus_5","browserName":"Firefox"}}
> info: Client User-Agent string: Apache-HttpClient/4.3.2 (java 1.5)
> info: [debug] Using local app from command line: C:\Appium\android-server-2.38.0.apk
> info: [debug] Creating new appium session daa741f2-6153-441d-951e-b4f17f3e4e09
> info: Starting android appium
> info: [debug] Getting Java version
> info: Java version is: 1.7.0_55
> info: [debug] Using fast reset? false
> info: [debug] Preparing device for session
> info: [debug] Checking whether app is actually present
> info: [debug] Checking whether adb is present
> info: [debug] Using adb from C:\Program Files (x86)\Android\sdk\platform-tools\adb.exe
> info: [debug] Trying to find N5-Emulator emulator
> info: [debug] Getting connected emulators
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: "C:\Program Files (x86)\Android\sdk\platform-tools\adb.exe" devices
> info: [debug] 1 device(s) connected
> info: [debug] 1 emulator(s) connected
> info: [debug] Sending telnet command to device: avd name
> info: [debug] Getting running emulator port
> info: [debug] Socket connection to device created
> info: [debug] Socket connection to device ready
> info: [debug] Telnet command got response: N5-Emulator
> info: [debug] Found emulator N5-Emulator in port 5556
> info: [debug] Setting device id to emulator-5556
> info: [debug] Did not launch AVD because it was already running.
> info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
> info: [debug] executing cmd: "C:\Program Files (x86)\Android\sdk\platform-tools\adb.exe" -s emulator-5556 wait-for-device
> info: [debug] executing cmd: "C:\Program Files (x86)\Android\sdk\platform-tools\adb.exe" -s emulator-5556 shell "echo 'ready'"
> info: [debug] Starting logcat capture
> info: [debug] Getting device API level
> info: [debug] executing cmd: "C:\Program Files (x86)\Android\sdk\platform-tools\adb.exe" -s emulator-5556 shell "getprop ro.build.version.sdk"

在所有这些之后,我在模拟器上看到一个空白屏幕,上面写着“WebDriver就绪”,就是这样,它不会打开浏览器或任何东西。任何帮助都将不胜感激。

我知道这个问题很老了。但是可以使用Appium为Android功能测试框架找到一个样例工作模板,它是Java的,从代码中启动Appium服务器。这意味着,在运行这些测试之前,您不必每次都启动Appium应用程序,而且它也可以轻松地集成到CI服务器。

我的建议是,在编写任何代码之前,请先手动尝试,这样当您启动并运行所有应用程序时,就很容易将其注入代码

请检查以下要求:

  • 在服务器部件(Appium)上
  • 发射活动是真的吗
  • 模拟器名称正确吗
  • API级别是否与模拟器相同
在代码端(java、pyhton、c#……):

  • 检查服务器中提供的所有数据是否被“注入”到所需的功能中
检查此链接,这是一个很好的起点:

您用@AfterMethod注释的方法看起来如何?您好,在@AfterMethod中,我想我刚才调用的是
driver.close();driver.quit()但我只是凭记忆说话,因为出于逻辑原因,我早就放弃让它工作了!我明白了,对我来说,放弃这样的事情也是一样的。似乎一些被调用的方法没有实现。和使用.close方法一样,我开始意识到appium只适用于测试应用程序,而不适用于在使用chrome或firefox等浏览器的网站上测试移动兼容性。我真的希望有人能证明我错了。你有没有发现任何测试手机兼容性的方法,似乎手机兼容性测试是一种经验?