Skip to content

Instantly share code, notes, and snippets.

View tourdedave's full-sized avatar

Dave Piacente tourdedave

  • Applitools
  • Takoma Park, MD
View GitHub Profile

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 '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
require 'selenium-webdriver'
class BasePage
def initialize(driver)
@driver = driver
end
def visit(url)
@driver.get url
Feature: The shopping cart should be able to accept products chosen by user.
# This would be better written from the users's perspective since that is what the scenarios entail
# e.g., Feature: Users can add products to their shopping cart
Scenario: Anonymous user adds product to the cart
Given I am on a product page
When I click on Add To Cart button
And I click on the Add to Cart button in the product description modal
Then I should see "$68.99" in the grand total section
And I should see "You have 1 item ($68.99) in your shopping cart." in the cart summary