简体   繁体   English

通过Appium在Android OS上运行Selenium Test

[英]Running Selenium Test on Android OS through Appium

I'm trying to run my selenium test on android emulator but this is not working properly. 我试图在android模拟器上运行我的硒测试,但这不能正常工作。 I write my code in java using eclipse and the setup is as follows 1. selenium-server-standalone-jar.2.44.0 2. testng-6.8.jar 3. appium 1.3.4.1 and these are the capabilities I'm sending to Appium 我使用eclipse在Java中编写代码,设置如下:1. selenium-server-standalone-jar.2.44.0 2. testng-6.8.jar 3. appium 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);

This is the output I usually get from Eclipse 这是我通常从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设置的屏幕截图

This is the output I usually get from Appium 这是我通常从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"

And after all this I get a blank screen on the emulator saying "WebDriver Ready" and that's it, it doesn't open a browser or anything. 毕竟,我在模拟器上得到了一个空白屏幕,上面写着“ WebDriver Ready”,仅此而已,它没有打开浏览器或任何东西。 Any help would be greatly appreciated. 任何帮助将不胜感激。

I know this question is very old. 我知道这个问题很老了。 But find a sample working template for Android functional testing framework using Appium here , which is in Java and starts Appium server from within the code. 但是,请在此处找到使用Appium的Android功能测试框架的示例工作模板,该模板是Java,可以从代码中启动Appium服务器。 Means, you don't have to start Appium app each time before running these tests and also it can be easily integrated to CI servers. 意味着,您不必在运行这些测试之前每次都启动Appium应用,并且它可以轻松集成到CI服务器。

My suggestion before writing any code, try manually first, so when You got all up and running than its really easy to pour into code. 我的建议是,在编写任何代码之前,请先手动尝试,这样,当您全部投入使用并投入运行时,它真的很容易投入代码中。

Please check following requirements: 请检查以下要求:

  • on server part (Appium) 在服务器部分(Appium)上
  • is launch activity true, 发射活动是真的吗?
  • is simulator name correct, 模拟器名称正确吗?
  • is API level same as simulator, API级别与模拟器相同

on code side (java, pyhton, c#...): 在代码方面(java,pyhton,c#...):

  • check if all data provided in server is being "injected" in desired capabilities 检查服务器中提供的所有数据是否都以所需的功能“注入”

check this link, its a good point to start: https://appium.io/docs/en/writing-running-appium/running-tests/#running-your-test-app-with-appium-android 检查此链接,这是一个很好的起点: https : //appium.io/docs/en/writing-running-appium/running-tests/#running-your-test-app-with-appium-android

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM