我一直在尝试让 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/