Created
July 1, 2016 18:38
-
-
Save p00j4/662c1a2c686cbe844ccef6a36101d291 to your computer and use it in GitHub Desktop.
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 Problem | |
Just like any other browser except firefox, you need additional setup for OperaDriver too. | |
A Solution | |
Let's step through how to do it and make sure it's working. | |
An Example | |
The prebuilt OperaDriver executable can be downloaded from here (https://github.com/operasoftware/operaprestodriver/downloads). Download it, double-click it, and click Trust when prompted. | |
Now if we open up an interactive Ruby terminal (e.g., irb) and launch a Selenium instance, here's what we'd see. | |
> irb | |
irb(main):001:0> require 'selenium-webdriver' | |
irb(main):002:0> driver = Selenium::WebDriver.for :opera | |
A successful communication between Safari and the Selenium Driver extension has occurred. | |
Now let's wire up a simple test so we can see that everything works as expect. | |
# filename: ruby.rb | |
require 'selenium-webdriver' | |
require 'rspec/expectations' | |
include RSpec::Matchers | |
def setup | |
opera_path = File.join(Dir.pwd, '..', '..',"vendor","operadriver") | |
Selenium::WebDriver::Opera.driver_path = opera_path | |
@driver = Selenium::WebDriver.for :opera | |
end | |
def teardown | |
@driver.quit | |
end | |
def run | |
setup | |
yield | |
teardown | |
end | |
run do | |
@driver.get 'http://the-internet.herokuapp.com' | |
expect(@driver.title).to eql 'The Internet' | |
end | |
Expected Behavior | |
When you save the file and run it (e.g., ruby safari.rb from the command-line), here is what will happen: | |
Opera opens | |
The home page of the-internet loads | |
The title of the page is checked to make sure it's what we expect | |
Opera closes | |
Happy Testing! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment