Download - selenium-2-mobile-web-testing
![Page 1: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/1.jpg)
Testing the Mobile Web with Selenium 2
Jason HugginsCo-creator, The Selenium ProjectCo-founder, CTO, Sauce Labs Inc
twitter: @hugsemail: [email protected]
![Page 2: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/2.jpg)
Selenium 2: Why and What
![Page 3: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/3.jpg)
Mobile
![Page 4: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/4.jpg)
Types of Mobile Testing
• Emulator
• Real device (tethered to workstation)
• Real device in a real location on a real network
![Page 5: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/5.jpg)
Native vs Web
![Page 6: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/6.jpg)
Life before the Web
Total Application Market
![Page 7: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/7.jpg)
Total Application Market
JS+HTML
Yesterday
![Page 8: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/8.jpg)
Total Application Market
JS+HTML5
Today
![Page 9: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/9.jpg)
Data?
![Page 10: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/10.jpg)
![Page 11: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/11.jpg)
Sencha
![Page 12: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/12.jpg)
SproutCore
![Page 13: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/13.jpg)
PhoneGap
![Page 14: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/14.jpg)
Total Application Market
JS+HTML5
TodaySelenium lives here!
![Page 15: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/15.jpg)
![Page 16: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/16.jpg)
Total Application Market
JS+HTML5
TodaySelenium lives here!
![Page 17: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/17.jpg)
Total Application Market
JS+HTML5
TomorrowSelenium lives here!
![Page 18: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/18.jpg)
Mobile - How?
![Page 19: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/19.jpg)
Checkout Selenium
![Page 20: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/20.jpg)
Android
![Page 21: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/21.jpg)
Download Android SDK
![Page 22: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/22.jpg)
Unpack
~/android_sdk
![Page 23: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/23.jpg)
Update
$ cd ~/android_sdk/tools$ ./android update sdk
![Page 24: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/24.jpg)
Create AVD
$ ./android create avd \ -n my_android \ -t 8 \ -c 100M
![Page 25: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/25.jpg)
Start Emulator
$ ./emulator -avd my_android \ -no-audio \ -no-boot-anim \ -scale .8
![Page 26: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/26.jpg)
Install Selenium APK
$ cd ~/android_sdk/platform-tools/$ ./adb -e install \ -r ~/selenium/android/prebuilt/android-server.apk
![Page 27: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/27.jpg)
Port Forwarding
$ ./adb forward tcp:8080 tcp:8080
![Page 28: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/28.jpg)
Launch App
$ adb -s shell am start -n \ org.openqa.selenium.android.app/ org.openqa.selenium.android.app.MainActivity
![Page 29: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/29.jpg)
iPhone
![Page 30: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/30.jpg)
Open in XCode
$ open ~/selenium/iphone/iWebDriver.xcodeproj/
![Page 31: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/31.jpg)
Build & Run
![Page 32: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/32.jpg)
iphonesim
![Page 33: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/33.jpg)
Demo!
![Page 34: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/34.jpg)
Selenium 2 - The Moviehttp://www.youtube.com/watch?v=IUUcEIfkOEY
![Page 35: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/35.jpg)
The Code:# Import the Selenium 2 namespace (aka "webdriver")from selenium import webdriver
# Run one of the four following commands:
# iPhonedriver = webdriver.Remote(browser_name="iphone", command_executor='http://172.24.101.36:3001/hub')
# Androiddriver = webdriver.Remote(browser_name="android", command_executor='http://127.0.0.1:8080/hub')
# Google Chrome driver = webdriver.Chrome()
# Firefox driver = webdriver.Firefox()
![Page 36: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/36.jpg)
The Code:# The actual test scenario: Test the codepad.org code execution service.
# Go to codepad.orgdriver.get('http://codepad.org')
# Select the Python language optionpython_link = driver.find_elements_by_xpath("//input[@name='lang' and @value='Python']")[0]python_link.click()
# Enter some text!text_area = driver.find_element_by_id('textarea')text_area.send_keys("print 'Hello,' + ' World!'")
# Submit the form!submit_button = driver.find_element_by_name('submit')submit_button.click()
# Make this an actual test. Isn't Python beautiful?assert "Hello, World!" in driver.get_page_source()
# Close the browser!driver.quit()
![Page 37: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/37.jpg)
LinksFor More Information:✓http://seleniumhq.org
✓http://code.google.com/p/selenium
✓http://saucelabs.com/docs/selenium2
✓http://twitter.com/hugs
Demo Screencast:✓http://www.youtube.com/watch?v=IUUcEIfkOEY
Code:✓http://gist.github.com/830011
![Page 38: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/38.jpg)
One More Thing:
![Page 39: selenium-2-mobile-web-testing](https://reader033.vdocuments.net/reader033/viewer/2022051515/54c923844a7959873a8b4648/html5/thumbnails/39.jpg)
Thanks!Jason Huggins
Co-creator, The Selenium ProjectCo-founder, CTO, Sauce Labs Inc
twitter: @hugsemail: [email protected]