From 7ed3c6c1903dba42ea0f0f2325bc5ad399e6f9a4 Mon Sep 17 00:00:00 2001 From: Sathish Gogineni Date: Fri, 10 Apr 2015 10:47:34 +0100 Subject: [PATCH] Replaced wait function with Selenium wait. --- .../cucumber_ios_web/features/step_definitions/steps.rb | 7 +++---- .../examples/ruby/cucumber_ios_web/features/support/env.rb | 7 +------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/sample-code/examples/ruby/cucumber_ios_web/features/step_definitions/steps.rb b/sample-code/examples/ruby/cucumber_ios_web/features/step_definitions/steps.rb index c9bdcb5a..573ab37f 100644 --- a/sample-code/examples/ruby/cucumber_ios_web/features/step_definitions/steps.rb +++ b/sample-code/examples/ruby/cucumber_ios_web/features/step_definitions/steps.rb @@ -15,23 +15,22 @@ # https://www.relishapp.com/rspec/rspec-expectations/docs Given(/^I have entered ([^"]*) into Email field$/) do |value| @driver.find_element(id:'fbemail').send_keys(value) - wait(timeout:2,message:'Text not entered into email').until { @driver.find_element(id:'fbemail').attribute('value').eql?value } + Selenium::WebDriver::Wait.new(timeout:2,message:'Text not entered into email').until { @driver.find_element(id:'fbemail').attribute('value').eql?value } end And(/^I have entered ([^"]*) into Comments field$/) do |value| @driver.find_element(id:'comments').send_keys(value) - wait(timeout:2,message:'Text not entered into comments').until { @driver.find_element(id:'comments').attribute('value').eql?value } + Selenium::WebDriver::Wait.new(timeout:2,message:'Text not entered into comments').until { @driver.find_element(id:'comments').attribute('value').eql?value } end When(/^I click on ([^"]*)$/) do |va| element = @driver.find_element(id:va) raise 'No link found' unless element.displayed? element.click - wait.until { @driver.title.start_with?'I am another page title' } + Selenium::WebDriver::Wait.new.until { @driver.title.start_with?'I am another page title' } end Then(/^I am on other page$/) do element = @driver.find_element(id:'i_am_an_id') - element.displayed? raise "Doesn't open next page" unless element.text.eql?'I am another div' end \ No newline at end of file diff --git a/sample-code/examples/ruby/cucumber_ios_web/features/support/env.rb b/sample-code/examples/ruby/cucumber_ios_web/features/support/env.rb index 3a016fba..7d36de51 100644 --- a/sample-code/examples/ruby/cucumber_ios_web/features/support/env.rb +++ b/sample-code/examples/ruby/cucumber_ios_web/features/support/env.rb @@ -26,11 +26,6 @@ class AppiumWorld @driver = $driver.start_driver @driver.get('http://saucelabs.com/test/guinea-pig') - wait(timout:3).until { @driver.title.start_with?'I am a page title' } - + Selenium::WebDriver::Wait.new(timout:3).until { @driver.title.start_with?'I am a page title' } } After { $driver.driver_quit } - -def wait(opts={}) - Selenium::WebDriver::Wait.new(opts) -end