selenium-2-mobile-web-testing

39
Testing the Mobile Web with Selenium 2 Jason Huggins Co-creator, The Selenium Project Co-founder, CTO, Sauce Labs Inc twitter: @hugs email: [email protected]

Upload: hugs

Post on 29-Jan-2015

105 views

Category:

Technology


0 download

DESCRIPTION

How to test mobile web applications with Selenium 2.

TRANSCRIPT

Page 1: selenium-2-mobile-web-testing

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

Selenium 2: Why and What

Page 3: selenium-2-mobile-web-testing

Mobile

Page 4: selenium-2-mobile-web-testing

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

Native vs Web

Page 6: selenium-2-mobile-web-testing

Life before the Web

Total Application Market

Page 7: selenium-2-mobile-web-testing

Total Application Market

JS+HTML

Yesterday

Page 8: selenium-2-mobile-web-testing

Total Application Market

JS+HTML5

Today

Page 9: selenium-2-mobile-web-testing

Data?

Page 10: selenium-2-mobile-web-testing
Page 11: selenium-2-mobile-web-testing

Sencha

Page 12: selenium-2-mobile-web-testing

SproutCore

Page 13: selenium-2-mobile-web-testing

PhoneGap

Page 14: selenium-2-mobile-web-testing

Total Application Market

JS+HTML5

TodaySelenium lives here!

Page 15: selenium-2-mobile-web-testing
Page 16: selenium-2-mobile-web-testing

Total Application Market

JS+HTML5

TodaySelenium lives here!

Page 17: selenium-2-mobile-web-testing

Total Application Market

JS+HTML5

TomorrowSelenium lives here!

Page 18: selenium-2-mobile-web-testing

Mobile - How?

Page 19: selenium-2-mobile-web-testing

Checkout Selenium

Page 20: selenium-2-mobile-web-testing

Android

Page 21: selenium-2-mobile-web-testing

Download Android SDK

Page 22: selenium-2-mobile-web-testing

Unpack

~/android_sdk

Page 23: selenium-2-mobile-web-testing

Update

$ cd ~/android_sdk/tools$ ./android update sdk

Page 24: selenium-2-mobile-web-testing

Create AVD

$ ./android create avd \ -n my_android \ -t 8 \ -c 100M

Page 25: selenium-2-mobile-web-testing

Start Emulator

$ ./emulator -avd my_android \ -no-audio \ -no-boot-anim \ -scale .8

Page 26: selenium-2-mobile-web-testing

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

Port Forwarding

$ ./adb forward tcp:8080 tcp:8080

Page 28: selenium-2-mobile-web-testing

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

iPhone

Page 30: selenium-2-mobile-web-testing

Open in XCode

$ open ~/selenium/iphone/iWebDriver.xcodeproj/

Page 31: selenium-2-mobile-web-testing

Build & Run

Page 32: selenium-2-mobile-web-testing

iphonesim

Page 33: selenium-2-mobile-web-testing

Demo!

Page 34: selenium-2-mobile-web-testing

Selenium 2 - The Moviehttp://www.youtube.com/watch?v=IUUcEIfkOEY

Page 35: selenium-2-mobile-web-testing

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

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

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

One More Thing:

Page 39: selenium-2-mobile-web-testing

Thanks!Jason Huggins

Co-creator, The Selenium ProjectCo-founder, CTO, Sauce Labs Inc

twitter: @hugsemail: [email protected]