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
import org.openqa.selenium.*; | |
import org.openqa.selenium.firefox.FirefoxDriver; | |
import java.util.concurrent.TimeUnit; | |
public class Tweet { | |
public static void goTweet() throws Exception { | |
WebDriver driver = new FirefoxDriver(); | |
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); | |
driver.get("http://twitter.com"); |
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
def tearDown(self): | |
passed = {'passed': self._exc_info() == (None, None, None)} | |
self.selenium.set_context("sauce: job-info=%s" % json.dumps(passed)) | |
self.selenium.stop() |
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
import time, re | |
from selenium import selenium | |
class implicitWaitSelenium(selenium): | |
""" | |
Extending the regular selenium class to add implicit waits | |
""" | |
def __init__(self, *args): | |
self.implicit_wait = 30 |
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
class SeleniumTestCase(TestCase): | |
# Let us just call self.click or self.type instead of self.selenium.type | |
def __getattr__(self, name): | |
if hasattr(self, 'selenium'): | |
return getattr(self.selenium, name) | |
raise AttributeError(name) | |
# Ignore open commands that fail (same needs to be don for wait_for_page_to_load) | |
def open(self, url, ignoreResponseCode=True): |
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
class Selenium2TestCase(TestCase): | |
def report_pass_fail(self): | |
base64string = base64.encodestring('%s:%s' % (config['username'], | |
config['access-key']))[:-1] | |
result = json.dumps({'passed': self._exc_info() == (None, None, None)}) | |
connection = httplib.HTTPConnection(self.config['host']) | |
connection.request('PUT', '/rest/v1/%s/jobs/%s' % (self.config['username'], | |
self.driver.session_id), | |
result, |
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
#!/bin/bash | |
# Automatically adds your Selenium wiki name in case it's missing | |
# Place in selenium/.git/hooks | |
# chmod +x selenium/.git/hooks/commit-msg | |
# Append 'export SELENIUM_WIKI_NAME="YourWikiName"' to your bashrc/zshrc | |
echo "Checking commit message..." | |
if [ -z "$(grep -e "^$SELENIUM_WIKI_NAME: " $1)" ]; then | |
echo "Missing Wiki name in commit message, appending" |
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
In [2]: class C(object): | |
...: def hi(self, k, d=dict()): | |
...: d[k] = 1 | |
...: print d | |
...: | |
In [3]: c = C() | |
In [4]: c.hi(1) | |
{1: 1} |
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
#!/bin/bash | |
# Setup and start Sauce Connect for your TravisCI build | |
# This script requires your .travis.yml to include the following two private env variables: | |
# SAUCE_USERNAME | |
# SAUCE_ACCESS_KEY | |
# Follow the steps at https://saucelabs.com/opensource/travis to set that up. | |
# | |
# Curl and run this script as part of your .travis.yml before_script section: | |
# before_script: |
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
from threading import Thread | |
from selenium import selenium | |
import time | |
try: | |
import json | |
except ImportError: | |
import simplejson as json | |
USERNAME = "USERNAME" | |
ACCESS_KEY = "ACCESS-KEY" |
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
#!/usr/bin/env python | |
import os | |
import time | |
import subprocess | |
import tempfile | |
import zipfile | |
import urllib | |
import logging |
OlderNewer