简体   繁体   中英

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. 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

@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

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

> 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. 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. 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.

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)
  • is launch activity true,
  • is simulator name correct,
  • is API level same as simulator,

on code side (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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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