Skip to content

Instantly share code, notes, and snippets.

require "selenium-webdriver"
require "selenium/rspec/spec_helper" # where is this coming from? what does it do? (jari)
require "spec/test/unit" # this looks outdated - should just be require "rspec" (jari)
describe "base.sel" do
before(:all) do
@verification_errors = []
@driver = Selenium::WebDriver.for :firefox
@driver.manage.timeouts.implicit_wait = 30
@ivaravko
ivaravko / test.rb
Created August 9, 2011 09:28 — forked from jarib/test.rb
require 'selenium-webdriver'
browser = Selenium::WebDriver.for :firefox
begin
browser.get "data:text/html;content-type=utf-8,#{URI.escape DATA.read}"
browser.find_element(:tag_name => "div").click
browser.switch_to.alert.accept
ensure
browser.quit
@ivaravko
ivaravko / file.rb
Created August 9, 2011 09:28 — forked from jarib/file.rb
def element_present?(how, what)
@driver.find_element(how, what)
true
rescue Selenium::WebDriver::Error::NoSuchElementError
false
end
require 'selenium-webdriver'
d = Selenium::WebDriver.for :firefox
begin
d.get "data:text/html,#{URI.escape DATA.read}"
d.find_elements(:tag_name => "option").last.click
sleep
ensure
d.quit
end
@ivaravko
ivaravko / file.rb
Created August 9, 2011 08:46 — forked from jarib/file.rb
require 'selenium/server'
server = Selenium::Server.new "/mnt/jobs/rake/selenium-server-standalone-2.2.0.jar", :background => true
server.start
# code
server.stop
{:x=>"", :y=>""}
{:x=>"100", :y=>"2279"}
{:x=>"200", :y=>"2379"}
{:x=>"300", :y=>"2479"}
ReplSetConnection.new(['db1.app.com'], ['db2.app.com'],
:rs_name => "myapp")
@ivaravko
ivaravko / file.rb
Created July 21, 2011 19:10 — forked from jarib/file.rb
e = @driver.find_element(:xpath, "//span[text()='IL-4']")
@driver.action.click_and_hold(e).
move_to(e, 0, 10).
release(e).
perform
require 'selenium-webdriver'
d = Selenium::WebDriver.for :firefox
begin
d.get "data:text/html,#{URI.escape DATA.read}"
d.find_elements(:tag_name => "option").last.click
sleep
ensure
d.quit
end
require 'selenium-webdriver'
require 'rack'
require 'rack/handler/thin'
class IframeServer
def start
@pid = fork { Rack::Handler::Thin.run(self, :Port => 9292) }
poller = Selenium::WebDriver::SocketPoller.new("localhost", 9292, 30)
raise "could not start #{self.inspect}" unless poller.connected?