android - 在 Android 上运行 Selenium 测试

标签 android testing selenium command-prompt

我一直在尝试让 Selenium 服务器运行现有的测试套件(在 Selenium IDE 中制作)以在多个目标平台上运行。我正在使用批处理文件,因为我们想对每晚/每周的工作运行测试。 我有以下内容:

@echo off
cls

echo Launching Selenium under Internet Explorer
java -jar "c:\selenium\selenium-server-standalone-2.5.0.jar" -trustAllSSLCertificates -multiwindow -htmlSuite "*iehta" "http://mywebsite.com" "c:\selenium\tests\mytest.html" "c:\selenium\results\ie.html"
echo completed....
echo ---------------------------------------------------------------------------------

echo Launching Selenium under Firefox
java -jar "c:\selenium\selenium-server-standalone-2.5.0.jar" -trustAllSSLCertificates -multiwindow -htmlSuite "*firefox" "http://mywebsite.com" "c:\selenium\tests\mytest.html" "c:\selenium\results\firefox.html"
echo completed....
echo ---------------------------------------------------------------------------------

echo Launching Selenium under Google Chrome
java -jar "c:\selenium\selenium-server-standalone-2.5.0.jar" -trustAllSSLCertificates -multiwindow -htmlSuite "*googlechrome" "http://mywebsite.com" "c:\selenium\tests\mytest.html" "c:\selenium\results\chrome.html"
echo completed....

echo ---------------------------------------------------------------------------------
echo Launching Selenium under Opera
java -jar "c:\selenium\selenium-server-standalone-2.5.0.jar" -trustAllSSLCertificates -multiwindow -htmlSuite "*opera" "http://mywebsite.com" "c:\selenium\tests\mytest.html" "c:\selenium\results\opera.html"
echo completed....

echo ---------------------------------------------------------------------------------
echo Launching Selenium under Android
emulator -avd testdroid -no-boot-anim -scale .6
echo Waiting for device to connect...
adb wait-for-device
adb devices
echo Forwarding tcp port...
adb -s emulator-5554 forward tcp:8080 tcp:8080
echo Unlocking device...
adb shell input keyevent 82
echo Running Selenium...
java -jar c:\selenium\selenium-server-standalone-2.5.0.jar -proxyInjectionMode -trustAllSSLCertificates -htmlSuite "*custom adb -s emulator-5554 shell am start -a android.intent.action.VIEW -d http://localhost:4444/wd/hub/ -n org.openqa.selenium.android.app/org.openqa.selenium.android.app.MainActivity" "http://mywebsite.com" "c:\selenium\tests\mytest.html" "c:\selenium\results\android.html"
rem echo completed....
rem adb kill-server

就目前而言,这似乎可行,但是: IE 在测试早期锁定,最终会发出脚本/内存警告,但整个应用程序变得无响应。

Android SDK 确实启动了我的测试 AVD,解锁并启动了 webdriver。但这就是它所做的全部。

所以我主要关心的是如何让 Android webdriver 开始运行测试。 如果有人对 IE 有想法那会很好,但 Android 才是真正的问题。

最佳答案

最好的办法是将测试导出为普通 WebDriver 测试(不使用 WebDriverBackedSelenium)并使用 AndroidDriver 运行它。

我们从未像您一样使用 Selenium Core 进行过测试,所以我怀疑它不会按预期工作。

关于android - 在 Android 上运行 Selenium 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7348818/

相关文章:

javascript - 列出在 PhantomJS 中加载的页面的所有 DOM 事件

c++ - 为测试用例捕获系统日志

python - 为什么 switch_to_window() 方法不适用于 Python 中的 selenium webdriver?

python - 从需要登录的社交媒体网站抓取最新帖子时,如何保持不被发现?

本地图区域自动移动时,Android map v2 变得低质量

java - 样式 toast 背景 - 找不到与给定名称匹配的资源

java - 带按钮和 EditText 的 ListView

android - 适用于 Amazon Kindle HDX 7"高清屏幕的正确布局资源文件夹

testing - 是否有必要在所有浏览器上运行自动化脚本(例如 Selenium 脚本)?

java - 如何在 Selenium 中运行高优先级测试