Skip to content

Instantly share code, notes, and snippets.

View tourdedave's full-sized avatar

Dave Piacente tourdedave

View GitHub Profile

Tying It All Together

You'll probably get a lot of mileage out of your test suite in its current form if you just run things from your computer, look at the results, and inform people on your team when there are issues. But that only helps you solve part of the problem.

The real goal in all of this is to find issues reliably, quickly, and continuously -- and ideally in sync with the development workflow you are a part of. In order to do that, we want to use a Continuous Integration (CI) server.

A Continuous Integration Primer

Continuous Integration (a.k.a. CI) is the practice of merging code that is actively being worked on into a shared mainline (e.g., trunk or master) as often as possible (e.g., several times a day). This is with the hopes of finding issues early and avoiding merging and integration issues that are not only considered a special kind of hell, but can dramatically slow the time it takes to release software.

1. Is converting my Selenium IDE script to a programming language to start using webdriver sufficient?

You may get some value out of exporting your existing IDE tests, but they will likely require a good amount of clean-up. You're likely to get more value out of identifying a few pieces of core functionality in the application you're testing, and writing new tests for this functionality in a programming language from scratch.

2. ­Can you please show some examples of a Selenium test report?

Here are two examples:

OpenGL compositor Initialized Succesfully.
Version: 2.1 INTEL-8.24.11
Vendor: Intel Inc.
Renderer: Intel HD Graphics 5000 OpenGL Engine
FBO Texture Target: TEXTURE_2D
Could not read chrome manifest 'file:///Applications/Firefox.app/Contents/MacOS/chrome.manifest'.
LOG addons.xpi: startup
LOG addons.xpi: Skipping unavailable install location app-system-share
LOG addons.xpi: checkForChanges
LOG addons.xpi: No changes found
# works
from selenium import webdriver as w
fp = w.FirefoxProfile()
fp.add_extension("/Users/tourdedave/Desktop/firebug-1.12.7.xpi")
d = w.Firefox(firefox_profile=fp)
d.get("http://the-internet.herokuapp.com")
require 'selenium-webdriver'
require 'browsermob/proxy'
require 'typhoeus'
def configure_proxy
proxy_binary = BrowserMob::Proxy::Server.new('./browsermob-proxy/bin/browsermob-proxy')
proxy_binary.start
proxy_binary.create_proxy
end
# 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')
# Encoding: utf-8
require 'selenium-webdriver'
require 'rspec-expectations'
include RSpec::Matchers
def setup(browser_name, browser_version)
caps = Selenium::WebDriver::Remote::Capabilities.send(browser_name.to_sym)
caps.platform = 'Windows XP'
caps.version = browser_version.to_s
require 'selenium-webdriver'
require 'rspec-expectations'
include RSpec::Matchers
driver = Selenium::WebDriver.for :firefox
driver.get 'http://the-internet.herokuapp.com/javascript_alerts'
driver.find_elements(css: 'button')[1].click
# to click the second button, [0] would click the first, and [2] (or [-1]) would click the last one
java -jar selenium-server-standalone-2.42.0.jar -role hub
def get_job_message
$job_message ? "\n " + $job_message : ''
end
def create_matcher_for(match_symbol, expected_str = nil, not_expected_str = nil, &block)
RSpec::Matchers.define match_symbol do |expected|
match do |actual|
case match_symbol
when :be_true
!!actual