Mobile Testing


Our grid currently supports iPhone (iOS 5.0), iPad (iOS 5.0), Android Jelly Bean, Samsung Galaxy Tab, Nexus One and Nexus S, HTC Desire and Opera Mobile Emulator.
Test how your website behaves on a cellphone and tablet by running a Selenium test with WebDriver.

Testing on mobile devices is only available with the WebDriver protocol.



Appium: test native and hybrid iOS apps

Appium

With the new Appium support on our grid, you can now test your native and hybrid iOS apps in our cloud.


Mobile optional desired capabilities

To run a test in landscape mode, please specify the landscape desired capability.

capabilities = { :landscape => true }


Below are some examples on how to test on mobile.


Ruby


  1. Install the webdriver gem:
    $ gem install selenium-webdriver
  2. Replace API_KEY and API_SECRET with your key and secret, which you can find in the member area

Phone_example_small
Android
Nexus_one_small
Nexus One
Nexuss_small
Nexus S
Htcdesire_small
HTC Desire

#!/usr/bin/env ruby
require "rubygems"
gem "selenium-client"
gem "selenium-webdriver"
require "selenium-webdriver"
require "selenium/client"


caps = Selenium::WebDriver::Remote::Capabilities.android
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 480
driver = Selenium::WebDriver.for(
  :remote,
  :url => "http://API_KEY:API_SECRET@hub.testingbot.com:4444/wd/hub",
  :http_client => client,
  :desired_capabilities => caps)
driver.navigate.to "http://www.google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!"
element.submit
puts driver.title
driver.quit
		

Samsung Galaxy Tab example:
Tab_example_small
#!/usr/bin/env ruby
require "rubygems"
gem "selenium-client"
gem "selenium-webdriver"
require "selenium-webdriver"
require "selenium/client"


caps = {
  :browserName => "galaxytab",
  :platform => "ANDROID"
}

client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 480

driver = Selenium::WebDriver.for(
  :remote,
  :url => "http://API_KEY:API_SECRET@hub.testingbot.com:4444/wd/hub",
  :http_client => client,
  :desired_capabilities => caps)
driver.navigate.to "http://www.google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!"
element.submit
puts driver.title
driver.quit
		


iPhone / iPad example:
Iphone_example_small
#!/usr/bin/env ruby
require "rubygems"
gem "selenium-client"
gem "selenium-webdriver"
require "selenium-webdriver"
require "selenium/client"


caps = {
  :browserName => "iphone", #or iPad
  :platform => "MAC"
}

client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 480

driver = Selenium::WebDriver.for(
  :remote,
  :url => "http://API_KEY:API_SECRET@hub.testingbot.com:4444/wd/hub",
  :http_client => client,
  :desired_capabilities => caps)
driver.navigate.to "http://www.google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!"
element.submit
puts driver.title
driver.quit
		


Opera Mobile Emulator:
Opera_mobile_small
#!/usr/bin/env ruby
require "rubygems"
gem "selenium-client"
gem "selenium-webdriver"
require "selenium-webdriver"
require "selenium/client"


caps = {
	:browserName => "opera",
	:platform => "LINUX",
	'opera.product' => 'mobile',
	'opera.arguments' => '-tabletui -displaysize 860x600'
}

client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 480

driver = Selenium::WebDriver.for(
  :remote,
  :url => "http://API_KEY:API_SECRET@hub.testingbot.com:4444/wd/hub",
  :http_client => client,
  :desired_capabilities => caps)
driver.navigate.to "http://www.google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!"
element.submit
puts driver.title
driver.quit
		
You can find more info on the OperaDriver page.