我正在尝试在 Android 模拟器上运行我的 Selenium 测试,但这无法正常工作。我使用 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);
这是我通常从 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 Ready”,就是这样,它不会打开浏览器或任何东西。任何帮助将不胜感激。
最佳答案
我知道这个问题很老了。但是使用 Appium 找到 Android 功能测试框架的示例工作模板 here ,它是 Java 语言,从代码中启动 Appium 服务器。这意味着,您不必每次在运行这些测试之前都启动 Appium 应用程序,并且它可以轻松集成到 CI 服务器。
关于java - 通过Appium在Android操作系统上运行Selenium测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27989554/