Here's an example with a hybrid app by the way.
>From the appium docs:
https://github.com/appium/appium/blob/master/docs/hybrid.md
```
require 'byebug'
require 'watir-webdriver'
capabilities = {
'browserName' => 'iOS',
'platform' => 'Mac',
'version' => '6.1',
'app' =>
'/Users/admin/Downloads/CollectionView-Simple/build/Release-iphonesimulator/CollViewSmpl.app'
}
server_url = "http://0.0.0.0:4723/wd/hub"
begin
wd = Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities,
:url => server_url)
b = Watir::Browser.new wd
b.element(:name, "Chicken Pics").click
b.element(:name, "Chicken Web").click
# Switch to operating on DOM instead of native elements
b.windows[0].use
# Now we're working with web elements
puts b.title
b.divs.each do |t|
puts t.text
end
# Back to interacting natively
b.execute_script("mobile: leaveWebView")
b.element(:name, "Chicken Calculator").click
# Get the text of the button
puts b.element(:xpath, "//window[1]/button[1]").attribute_value("name")
# Run a calculation
b.element(:xpath, "//window[1]/textfield[1]").when_present.send_keys "1"
b.element(:xpath, "//window[1]/textfield[2]").send_keys "2"
b.element(:name, "Calculate").click
# Get the resulting value
puts b.element(:xpath, "//window[1]/text[2]").text
rescue => e
puts e.message
puts "Backtrace:\n\t#{e.backtrace.join("\n\t")}"
ensure
b.close
end
```
---
Reply to this email directly or view it on GitHub:
https://github.com/watir/watir-webdriver/issues/238#issuecomment-33591559_______________________________________________
Wtr-development mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-development