From 1886e944636151f7c2e405e76d59d71526b0dd7b Mon Sep 17 00:00:00 2001 From: Felix Rodriguez Date: Fri, 20 Sep 2013 16:28:32 -0700 Subject: [PATCH] Update hybrid.md Added ruby syntax --- docs/hybrid.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docs/hybrid.md b/docs/hybrid.md index d7c709a66..4ad79cac4 100644 --- a/docs/hybrid.md +++ b/docs/hybrid.md @@ -97,3 +97,38 @@ Once installed you can start the proxy with the following command: remoteWebDriver.quit(); ``` +## Wd.ruby Code example using cucumber + +``` +TEST_NAME = "Example Ruby Test" +SERVER_URL = "http://127.0.0.1:4723/wd/hub" +APP_PATH = "https://dl.dropboxusercontent.com/s/123456789101112/ts_ios.zip" +capabilities = + { + 'browserName' => 'iOS 6.0', + 'platform' => 'Mac 10.8', + 'device' => 'iPhone Simulator', + 'app' => APP_PATH, + 'name' => TEST_NAME + } +@driver = Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities, :url => SERVER_URL) + +## I switch to the last window because its always the webview in our case, in other cases you may need to specify a window number +## View the appium logs while running @driver.window_handles to figure out which window is the one you want and find the associated number +## Then switch to it using @driver.switch_to_window("6") + +Given(/^I switch to webview$/) do + webview = @driver.window_handles.last + @driver.switch_to.window(webview) +end + +Given(/^I switch out of webview$/) do + @driver.executeScript("mobile: leaveWebView;") +end + +# Now you can use CSS to select an element inside your webview + +And(/^I click a webview button $/) do + $driver.find_element(:css, ".green_button").click +end +```