mobile testing with selenium 2 by jason huggins

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

Upload: sauce-labs

Post on 09-May-2015

16.532 views

Category:

Documents


2 download

DESCRIPTION

See the slides from Jason Huggins' March 16 presentation at the San Francisco Selenium Meetup on using Selenium 2 for mobile testing.

TRANSCRIPT

Page 1: Mobile Testing with Selenium 2 by Jason Huggins

Selenium 2Jason Huggins

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

twitter: @hugsemail: [email protected]

Page 2: Mobile Testing with Selenium 2 by Jason Huggins

Selenium 2: Why and What

Page 3: Mobile Testing with Selenium 2 by Jason Huggins

Mobile

Page 4: Mobile Testing with Selenium 2 by Jason Huggins

Types of Mobile Testing

• Emulator

• Real device (tethered to workstation)

• Real device in a real location on a real network

Page 5: Mobile Testing with Selenium 2 by Jason Huggins

Native vs Web

Page 6: Mobile Testing with Selenium 2 by Jason Huggins

Life before the Web

Total Application Market

Page 7: Mobile Testing with Selenium 2 by Jason Huggins

Total Application Market

JS+HTML

Yesterday

Page 8: Mobile Testing with Selenium 2 by Jason Huggins

Total Application Market

JS+HTML5

Today

Page 9: Mobile Testing with Selenium 2 by Jason Huggins

Data?

Page 10: Mobile Testing with Selenium 2 by Jason Huggins
Page 11: Mobile Testing with Selenium 2 by Jason Huggins

Sencha

Page 12: Mobile Testing with Selenium 2 by Jason Huggins

SproutCore

Page 13: Mobile Testing with Selenium 2 by Jason Huggins

PhoneGap

Page 14: Mobile Testing with Selenium 2 by Jason Huggins

Total Application Market

JS+HTML5

TodaySelenium lives here!

Page 15: Mobile Testing with Selenium 2 by Jason Huggins
Page 16: Mobile Testing with Selenium 2 by Jason Huggins

Total Application Market

JS+HTML5

TodaySelenium lives here!

Page 17: Mobile Testing with Selenium 2 by Jason Huggins

Total Application Market

JS+HTML5

TomorrowSelenium lives here!

Page 18: Mobile Testing with Selenium 2 by Jason Huggins

Mobile - How?

Page 19: Mobile Testing with Selenium 2 by Jason Huggins

Checkout Selenium

Page 20: Mobile Testing with Selenium 2 by Jason Huggins

Android

Page 21: Mobile Testing with Selenium 2 by Jason Huggins

Download Android SDK

Page 22: Mobile Testing with Selenium 2 by Jason Huggins

Unpack

~/android_sdk

Page 23: Mobile Testing with Selenium 2 by Jason Huggins

Update

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

Page 24: Mobile Testing with Selenium 2 by Jason Huggins

Create AVD

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

Page 25: Mobile Testing with Selenium 2 by Jason Huggins

Start Emulator

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

Page 26: Mobile Testing with Selenium 2 by Jason Huggins

Install Selenium APK

$ cd ~/android_sdk/platform-tools/$ ./adb -e install \ -r ~/selenium/android/prebuilt/android-server.apk

Page 27: Mobile Testing with Selenium 2 by Jason Huggins

Port Forwarding

$ ./adb forward tcp:8080 tcp:8080

Page 28: Mobile Testing with Selenium 2 by Jason Huggins

Launch App

$ adb -s shell am start -n \ org.openqa.selenium.android.app/ org.openqa.selenium.android.app.MainActivity

Page 29: Mobile Testing with Selenium 2 by Jason Huggins

iPhone

Page 30: Mobile Testing with Selenium 2 by Jason Huggins

Open in XCode

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

Page 31: Mobile Testing with Selenium 2 by Jason Huggins

Build & Run

Page 32: Mobile Testing with Selenium 2 by Jason Huggins

iphonesim

Page 33: Mobile Testing with Selenium 2 by Jason Huggins

Demo!

Page 34: Mobile Testing with Selenium 2 by Jason Huggins

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 35: Mobile Testing with Selenium 2 by Jason Huggins

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 36: Mobile Testing with Selenium 2 by Jason Huggins

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

Page 37: Mobile Testing with Selenium 2 by Jason Huggins

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: Mobile Testing with Selenium 2 by Jason Huggins

One More Thing:

Page 39: Mobile Testing with Selenium 2 by Jason Huggins

Thanks!Jason Huggins

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

twitter: @hugsemail: [email protected]