Reputation: 405
I am using Webdriver in Ruby, and I am using Aptana Studio as my IDE.
For example I have the following test script: require "selenium-webdriver"
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "http://google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!"
element.submit
puts driver.title
##TODO
driver.quit
Say if I want to come back and add another action on the TODO comment: driver.navigate.to "http://google.com/blahblah"
Assume this step is dependent on the above codes, is there a way that I can run just this line of code to see if it works?
Assume the test is growing large in the future, and I don't want to rerun the all test just to test the steps added later are working.
Thanks and cheers.
Upvotes: 1
Views: 151
Reputation: 32855
You need to setup a testing project with proper testing framework for this. Please Google ruby + selenium to get more inputs.
For example, put driver = Selenium::WebDriver.for :firefox
in test initialize, then all contents in different tests. With such a setup, you can select whichever test you want to test.
require 'selenium-webdriver'
require 'test/unit'
module Test
class GoogleTest < Test::Unit::TestCase
def setup
@driver = Selenium::WebDriver.for :firefox
end
def teardown
@driver.quit
end
def test_something
@driver.navigate.to "http://google.com"
element = @driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!"
element.submit
puts @driver.title
end
def test_something_else
@driver.navigate.to "http://google.com/blahblah"
# do some stuff
end
end
end
Upvotes: 1