Skip to content

Instantly share code, notes, and snippets.

@umaar
Created January 9, 2013 23:41
Show Gist options
  • Select an option

  • Save umaar/4498067 to your computer and use it in GitHub Desktop.

Select an option

Save umaar/4498067 to your computer and use it in GitHub Desktop.
require 'sim_launcher'
require 'selenium-webdriver'
simulator = SimLauncher::DirectClient.for_iphone_app( "iWebDriver.app", '6.0' )
simulator.relaunch()
# see if iWebDriver is loaded(contact the host)
# retry a few times just incase
connected = false
(0..2).each do
begin
Net::HTTP.new("localhost", 3005).start
connected = true
break
rescue
sleep(2)
end
end
unless connected
raise 'Could not launch iPhone webdriver'
end
@driver = Selenium::WebDriver.for :remote, :url => "http://localhost:3005/hub", :desired_capabilities => :iphone
@driver.navigate.to "http://google.com"
puts @driver.title
`/usr/bin/osascript -e 'application "iPhone Simulator" quit'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment