I am a total beginner of Ruby and Selenium and i want to use both =)
Selenium-webdriver gem - How do I find out which methods that this
gem contains or other gems?
Catch a bug – If a link or element is missing on the page how do I
catch this defect and output it and then continue with my test script?
Some design tips?
Plenty of methods are shown there and in the documentation. As for
catching missing elements, you have methods such as “present?” returning
a boolean value.
Plenty of methods are shown there and in the documentation. As for
catching missing elements, you have methods such as “present?” returning
a boolean value.
Plenty of methods are shown there and in the documentation. As for
catching missing elements, you have methods such as “present?” returning
a boolean value.
Thank you Joel I will check this out.
Best Regards
Mattias
Hi again,
What actually happens below? See my comments after #
Would really appreciate if someone wanted to take the time to explain.
driver = Selenium::WebDriver.for :firefox #instantiate driver with
Selenium and Webdriver methods?
driver.get “http://google.com”
element = driver.find_element :name => “q” # What happens here? :name =>
“q”?
element.send_keys “Cheese!”
element.submit
puts “Page title is #{driver.title}”
wait = Selenium::WebDriver::Wait.new(:timeout => 2)#Wait is a new class?
wait.until { driver.title.downcase.start_with? “cheese!” }#Verify that
cheese has been printed?
What actually happens below? See my comments after #
Would really appreciate if someone wanted to take the time to explain.
require ‘rubygems’ #lib?
You don’t need this in Ruby 1.9
require ‘selenium-webdriver’ #lib?
Have a look at this: Home - Watir-Melon
driver = Selenium::WebDriver.for :firefox #instantiate driver with
Selenium and Webdriver methods?
This just creates an instance of firefox with a temp profile which can
be controlled via Selenium-webdriver
driver.get “http://google.com”
element = driver.find_element :name => “q” # What happens here? :name =>
“q”?
The element on the page with the name “q” happens to be the search text
field. I recommend using Firebug to find out what each element can be
identified by.
element.send_keys “Cheese!”
element.submit
puts “Page title is #{driver.title}”
wait = Selenium::WebDriver::Wait.new(:timeout => 2)#Wait is a new class?
Watir-webdriver’s latest version has waiting built-in, it looks like
Selenium has a seperate wait module.
wait.until { driver.title.downcase.start_with? “cheese!” }#Verify that
cheese has been printed?
You’re passing a block to the wait module, until method which will stop
waiting once it evaluates to “true”. This waits until the page has
loaded to a point that it has changed the title of the browser window.
puts “Page title is #{driver.title}”
driver.quit
I’m not sure about Selenium, but with watir-webdriver using “close”
rather than “quit” cleans up the temp files as well.
Best Regards
Mattias
This is what the same sequence looks like with watir-webdriver:
require ‘watir-webdriver’
driver = Watir::Browser.new :firefox
driver.goto “http://google.com”
element = driver.text_field(:name => “q”)
element.set “Cheese!\n”
puts “Page title is #{driver.title}”
driver.wait_until { driver.title.downcase.start_with? “cheese!” }
puts “Page title is #{driver.title}”
driver.close
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.