Skip to content

Instantly share code, notes, and snippets.

View adamgoucher's full-sized avatar

adam goucher adamgoucher

View GitHub Profile
@adamgoucher
adamgoucher / selectwrapper.py
Created July 10, 2012 21:15
A Python list-like wrapper around WebDriver's support.select.Select class
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
locators = {
"fisc": (By.CSS_SELECTOR, '[name="mytextarea"][multiple]')
}
@adamgoucher
adamgoucher / TheEasyPart.py
Created June 15, 2012 14:17
parsing har files
import os.path
import pytest
import sys
f = os.path.join(os.path.dirname(__file__), "allievi.sssup.it.120601_0_89e253d69250548c5d814019fdd4f1ca.har.json")
def setup_module(module):
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
class TestHar(object):
@adamgoucher
adamgoucher / BrowserMobProxyTest.php
Created June 7, 2012 20:27
BrowserMobProxy and PHPWebDriver
<?php
require_once(dirname(__FILE__) . '/../PHPWebDriver/WebDriver.php');
require_once(dirname(__FILE__) . '/../PHPWebDriver/WebDriverProxy.php');
// yes, i know this is just local for me right now...
require_once '/Users/adam/work/PHPBrowserMobProxy/PHPBrowserMobProxy/Client.php';
class ProxyTest extends PHPUnit_Framework_TestCase {
protected static $driver;
protected static $client;
@adamgoucher
adamgoucher / Video.php
Created April 10, 2012 15:02
video element in php
<?php
require_once('Media.php');
class PHPWebDriver_WebDriver_Support_HTML5_Video extends PHPWebDriver_WebDriver_Support_HTML5_Media {
protected function gettable_properties() {
$properties = array("width", "height", "videoWidth", "videoHeight", "poster");
return array_merge(parent::$gettable_media_properties, $properties);
}
@adamgoucher
adamgoucher / log.js
Created April 8, 2012 18:34
selenium ide logging systems
var pref_service = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("extensions.selenium-ide.");
function Log(category) {
var log = this;
var self = this;
this.category = category;
function LogLevel(level, name) {
this.level = level;
this.name = name;
@adamgoucher
adamgoucher / webdriver_video.py
Created April 7, 2012 04:27
a basic example of using webdriver with html 5's video tag
# Copyright 2008-2009 WebDriver committers
# Copyright 2008-2009 Google Inc.
#
# 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 / HarFormatSchema.json
Created April 6, 2012 04:07
HAR Format Schema
{
"type": "object",
"properties": {
"log": {
"description": "HTTP Archive structure.",
"type": "object",
"properties": {
"version": {
"description": "HAR format version",
"type": "string",
@adamgoucher
adamgoucher / pondering.txt
Created March 8, 2012 02:41
Are you pondering what I am pondering?
I think so, Brain, but where are we going to find a duck and a hose at this hour?
I think so, but where will we find an open tattoo parlor at this time of night?
Wuh, I think so, Brain, but if we didn't have ears, we'd look like weasels.
Uh?; yeah, Brain, but where are we going to find rubber pants our size?
I think so, Brain, but balancing a family and a career ... ooh, it's all too much for me.
Wuh, I think so, Brain, but isn't Regis Philbin already married?
Wuh, I think so, Brain, but burlap chafes me so.
Sure, Brain, but how are we going to find chaps our size?
Uh, I think so, Brain, but we'll never get a monkey to use dental floss.
Uh, I think so Brain, but this time, you wear the tutu.
@adamgoucher
adamgoucher / promises.cf
Created February 7, 2012 16:17
how to use selenium and pear with cfengine
body common control
{
bundlesequence => { "packages", "channels", "prickly" };
}
#http://cfengine.com/manuals/CfengineStdLibrary.html#body-package_005fmethod-yum
body package_method yum
{
package_changes => "bulk";
package_list_command => "/usr/bin/yum list installed";
@adamgoucher
adamgoucher / WebDriverCookies.php
Created January 24, 2012 21:17
WebDriver and Cookies
<?php
require_once 'PHPUnit/Framework/TestCase.php';
require_once 'PHPWebDriver/WebDriver.php';
require_once 'PHPWebDriver/WebDriverActionChains.php';
class CookieTest extends PHPUnit_Framework_TestCase {
public function setUp() {
$web_driver = new PHPWebDriver_WebDriver("http://localhost:4444/wd/hub");
$this->session = $web_driver->session();
}