This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def element_present?(how, what) | |
@driver.find_element(how, what) | |
true | |
rescue Selenium::WebDriver::Error::NoSuchElementError | |
false | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
require 'selenium-webdriver' | |
browser = Selenium::WebDriver.for :firefox | |
begin | |
browser.get "data:text/html;content-type=utf-8,#{URI.escape DATA.read}" | |
frame = browser.find_element(:tag_name => "iframe") | |
p frame |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'selenium-webdriver' | |
browser = Selenium::WebDriver.for :firefox | |
begin | |
browser.get "data:text/html;content-type=utf-8,#{URI.escape DATA.read}" | |
opts = browser.find_elements(:tag_name => "option") | |
opts[0].click | |
opts[1].click | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'selenium-webdriver' | |
ctrl = Selenium::WebDriver::Platform.os == :macosx ? :command : :control | |
browser = Selenium::WebDriver.for :chrome | |
begin | |
browser.get "data:text/html;content-type=utf-8,#{URI.escape DATA.read}" | |
receiver = browser.find_element(:id => "receiver") | |
receiver.send_keys 'foo' | |
receiver.send_keys [ctrl, 'a'], :backspace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'selenium-webdriver' | |
require 'pp' | |
dir = Dir.mktmpdir("modal-dialog") | |
htmls = DATA.read.scan(/--- (.+?) ---\n(.+?)(?=---|\z)/m) | |
htmls.each do |name, content| | |
File.open(File.join(dir, name), "w") { |io| io << content} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Get development tools installed | |
# | |
sudo yum install -y git cvs zlib-devel | |
sudo yum groupinstall -y "Development Tools" | |
# | |
# Install RVM | |
# | |
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
require 'sinatra' | |
set server: 'thin', connections: [] | |
get '/' do | |
halt erb(:login) unless params[:user] | |
erb :chat, locals: { user: params[:user].gsub(/\W/, '') } | |
end | |
get '/stream', provides: 'text/event-stream' do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium.common.exceptions import NoSuchElementException, TimeoutException | |
class DomHelper(object): | |
driver = None | |
waiter = None | |
def open_page(self, url): | |
self.driver.get(url) |