-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbrowserstack_sample.rb
60 lines (49 loc) · 1.78 KB
/
browserstack_sample.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require 'rubygems'
require 'appium_lib'
require 'selenium-webdriver'
capabilities = {
# Specify device and os_version for testing
"platformName" => "iOS",
"platformVersion" => "13",
"deviceName" => "iPhone 11 Pro",
# Set URL of the application under test
"app" => "bs://<appID>",
# Set other BrowserStack capabilities
'bstack:options' => {
"projectName" => "First Ruby project",
"buildName" => "browserstack-build-1",
"sessionName" => "BStack single_test",
"debug" => "true",
"networkLogs" => "true",
# Set your access credentials
"userName": "BROWSERSTACK_USERNAME",
"accessKey": "BROWSERSTACK_ACCESS_KEY"
},
}
# Initialize the remote Webdriver using BrowserStack remote URL
# and desired capabilities defined above
appium_driver = Appium::Driver.new({
'caps' => capabilities,
'appium_lib' => {
:server_url => "http://hub.browserstack.com/wd/hub"
}}, true)
driver = appium_driver.start_driver
# Test case for the BrowserStack sample iOS app.
# If you have uploaded your app, update the test case here.
wait = Selenium::WebDriver::Wait.new(:timeout => 30)
wait.until { driver.find_element(:accessibility_id, "Text Button").displayed? }
textButton = driver.find_element(:accessibility_id, "Text Button")
textButton.click
wait.until { driver.find_element(:accessibility_id, "Text Input").displayed? }
textInput = driver.find_element(:accessibility_id, "Text Input")
textInput.send_keys("hello@browserstack.com"+"\n")
sleep 5
wait.until { driver.find_element(:accessibility_id, "Text Output").displayed? }
result = driver.find_element(:accessibility_id, "Text Output")
if (!result.nil?) && (result.text.eql? "hello@browserstack.com")
puts "Test Passed"
else
puts "Test Failed"
end
# Invoke driver.quit() after the test is done to indicate that the test is completed.
driver.quit