Skip to content
This repository was archived by the owner on Mar 23, 2020. It is now read-only.

Commit 59895bf

Browse files
author
Sathish Gogineni
committed
Replaced wait function with Selenium wait.
1 parent 11e4f99 commit 59895bf

File tree

2 files changed

+6
-9
lines changed
  • sample-code/examples/ruby/cucumber_ios_web/features

2 files changed

+6
-9
lines changed

sample-code/examples/ruby/cucumber_ios_web/features/step_definitions/steps.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,22 @@
1515
# https://www.relishapp.com/rspec/rspec-expectations/docs
1616
Given(/^I have entered ([^"]*) into Email field$/) do |value|
1717
@driver.find_element(id:'fbemail').send_keys(value)
18-
sleep(1)
19-
raise 'Text not entered into email' unless @driver.find_element(id:'fbemail').attribute('value').eql?value
18+
Selenium::WebDriver::Wait.new(timeout:2,message:'Text not entered into email').until { @driver.find_element(id:'fbemail').attribute('value').eql?value }
2019
end
2120

2221
And(/^I have entered ([^"]*) into Comments field$/) do |value|
2322
@driver.find_element(id:'comments').send_keys(value)
24-
raise 'Text not entered into comments' unless @driver.find_element(id:'comments').attribute('value').eql?value
23+
Selenium::WebDriver::Wait.new(timeout:2,message:'Text not entered into comments').until { @driver.find_element(id:'comments').attribute('value').eql?value }
2524
end
2625

2726
When(/^I click on ([^"]*)$/) do |va|
2827
element = @driver.find_element(id:va)
2928
raise 'No link found' unless element.displayed?
3029
element.click
31-
@wait.until { @driver.title.start_with?'I am another page title' }
30+
Selenium::WebDriver::Wait.new.until { @driver.title.start_with?'I am another page title' }
3231
end
3332

3433
Then(/^I am on other page$/) do
3534
element = @driver.find_element(id:'i_am_an_id')
36-
element.displayed?
3735
raise "Doesn't open next page" unless element.text.eql?'I am another div'
3836
end

sample-code/examples/ruby/cucumber_ios_web/features/support/env.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AppiumWorld
1616
# Load the desired configuration from appium.txt, create a driver then
1717
# Add the methods to the world
1818
caps = Appium.load_appium_txt file: File.expand_path('./', __FILE__), verbose: true
19-
$driver = Appium::Driver.new(caps)
19+
Appium::Driver.new(caps)
2020

2121
World do
2222
AppiumWorld.new
@@ -25,7 +25,6 @@ class AppiumWorld
2525
Before {
2626
@driver = $driver.start_driver
2727
@driver.get('http://saucelabs.com/test/guinea-pig')
28-
@wait = Selenium::WebDriver::Wait.new(:timeout => 10) # seconds
29-
@wait.until { @driver.title.start_with?'I am a page title' }
28+
Selenium::WebDriver::Wait.new(timeout:3).until { @driver.title.start_with?'I am a page title' }
3029
}
31-
After { $driver.driver_quit }
30+
After { $driver.driver_quit }

0 commit comments

Comments
 (0)