Skip to content

Instantly share code, notes, and snippets.

View adamgoucher's full-sized avatar

adam goucher adamgoucher

View GitHub Profile
@adamgoucher
adamgoucher / gist:3921739
Created October 20, 2012 02:22
how to use webdriver with py.test fixtures
from selenium.webdriver import Firefox
import pytest
class TestHighcharts(object):
@pytest.fixture(autouse=True)
def fixture(self, request):
request.instance.driver = Firefox()
request.instance.driver.get("http://localhost:9000")
def cleanup():
request.instance.driver.quit()
@adamgoucher
adamgoucher / gist:3823247
Created October 2, 2012 20:55
windows jre module
class jre {
file {'jre-7u7-windows-i586.exe':
source => 'puppet:///modules/jre/jre-7u7-windows-i586.exe'
}
# from https://gist.github.com/3813324
package { 'Java(TM) 7 Update 7':
ensure => installed,
source => '...\jre-7u7-windows-i586.exe',
install_options => [
@adamgoucher
adamgoucher / invalidssl.py
Created September 21, 2012 12:43
Messing around with accepting messed up certificates
from selenium.webdriver import Firefox
from selenium.webdriver import Remote
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import pytest
import time
class TestInvalidSSL(object):
def setup_method(self, method):
@adamgoucher
adamgoucher / latches.mxml
Created August 31, 2012 00:20
latches in flex
<fx:Script>
import flash.external.*;
public function initApp():void {
// flexpilot
FPBootstrap.flex_pilotLibPath = 'FlexPilot.swf';
FPBootstrap.init(stage);
// latch stuff
var latches:Object = new Object();
@adamgoucher
adamgoucher / pycon-doing-it-wrong.md
Created August 29, 2012 01:26
WebDriver; you are probably doing it wrong...

Selenium, and WebDriver by extension have a bad reputation for being unreliable, unmaintainable and slow. Care to guess whose fault it is? Have a mirror handy? The good news is that we know how to address these problems.

  • Page Objects FTW - 20 minutes
    • Locators
      • dynamic
    • Elements
      • input
      • select
      • checkbox
  • Actions
@adamgoucher
adamgoucher / qsta.txt
Created August 23, 2012 11:37
quicky security testing agendat
Security Testing
----------------
- its not paranoia if they really are after you
- https://www.owasp.org (top 10 is 2 years old, but still relevant)
- (a1) sql injection
- parameterized sql
- code review
- (a2) xss
- all input safe
- <script>alert('hello');</script>
@adamgoucher
adamgoucher / samplepageobject.php
Created August 22, 2012 21:36
sample page object in php
<?php
namespace WebDriver;
require_once('dashboard.php');
require_once(dirname(__FILE__) . '/../../../PHPWebDriver/WebDriverWait.php');
require_once(dirname(__FILE__) . '/../../../PHPWebDriver/WebDriverBy.php');
class SauceLoginPage {
private $locators = array(
"username" => array(\PHPWebDriver_WebDriverBy::ID, 'username'),
@adamgoucher
adamgoucher / PHPWebDriver_Support_WebDriverExpectedConditions.php
Created August 18, 2012 13:35
Initial PHPWebDriver_Support_WebDriverExpectedConditions class
<?php
// Copyright 2012-present Element 34
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@adamgoucher
adamgoucher / gist:3360560
Created August 15, 2012 14:23
Descriptors and @Property
class Select(Element, WebDriverSelect):
"""
This works for getting the current value of a select element, and for setting it
-- but fails for /also/ getting the 'options' that are available. Thinking that I
need to use my_select.selection with @property and @selection.setter and
my_select.options with @property
Now, what I would love is to still use __set__ and __get__ to interact with the
the select, but also be able to get the options...
"""
@adamgoucher
adamgoucher / dhx_combo_box.py
Created July 13, 2012 17:53
dhx_combo_box
import pytest
from selenium.webdriver import Firefox
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.select import Select
from selenium.common.exceptions import UnexpectedTagNameException
class ComboBox(object):
def __init__(self, webelement):
if webelement.tag_name.lower() != "div":