- Selenium 3 & geckodriver support
- Updated to latest version of supporting libraries
- Updated code examples for better Python 3 compliance
- Fixed errata
- Added collection of Python tips (as an accompanying PDF e-book)
This file contains 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' | |
require 'browsermob/proxy' | |
require 'rspec-expectations' | |
include RSpec::Matchers | |
require 'json' | |
def configure_proxy | |
proxy_binary = BrowserMob::Proxy::Server.new('./browsermob-proxy/bin/browsermob-proxy') |
This file contains 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
// in Base Page Object | |
public Boolean isDisplayed(By locator) { | |
try { | |
return find(locator).isDisplayed(); | |
} catch (org.openqa.selenium.NoSuchElementException exception) { | |
return false; | |
} | |
} | |
public Boolean isDisplayed(By locator, Integer timeout) { |
This file contains 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
""" | |
The element lookup for the assertion fails. | |
Adding a sleep of 0.5 seconds before it makes it work. | |
But this example worked without the sleep in 2.53.1 with Firefox 46. | |
Using: | |
- selenium 3.0.2 | |
- geckodriver 11.0.1 | |
- Firefox 50.0.1 | |
""" |
This file contains 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
test.afterEach(function() { | |
var testName = this.currentTest.fullTitle(), | |
testResult = (this.currentTest.state === 'passed') ? true : false; | |
driver.executeScript('sauce:job-name=' + testName); | |
driver.executeScript('sauce:job-result=' + testResult); | |
driver.quit(); | |
}); |
This file contains 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 'rspec/expectations' | |
include RSpec::Matchers | |
require 'eyes_selenium' | |
def setup | |
@eyes = Applitools::Eyes.new | |
@eyes.api_key = ENV['APPLITOOLS_API_KEY'] | |
caps = Selenium::WebDriver::Remote::Capabilities.internet_explorer | |
caps.version = '8' |
This file contains 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 'rspec/expectations' | |
include RSpec::Matchers | |
driver = Selenium::WebDriver.for :firefox | |
driver.get 'http://the-internet.herokuapp.com/exit_intent' | |
driver.action.move_by(5000, 0).perform | |
Selenium::WebDriver::Wait.new(timeout: 5).until { | |
driver.find_element(class: 'modal-body').displayed? |
This file contains 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
# pages/top-nav-widget.rb | |
module PageObject | |
module TopNavWidget | |
FORK_LINK = { css: 'img' } | |
end | |
end | |
# pages/login-page.rb | |
module PageObject | |
class LoginPage |
This file contains 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
class BasePage | |
def initialize(driver) | |
@driver = driver | |
driver.get ENV['base_url'] | |
end | |
def visit(url_path) | |
driver.get ENV['base_url'] + url_path | |
end | |
# ... |
This file contains 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' | |
@driver1 = Selenium::WebDriver.for :firefox | |
@driver2 = Selenium::WebDriver.for :firefox | |
@driver1.get 'http://google.com' | |
@driver2.get 'http://duckduckgo.com/' | |
@driver1.quit | |
@driver2.quit |