Skip to content

Instantly share code, notes, and snippets.

View santiycr's full-sized avatar
💭
Always learning

Santiago Suarez Ordoñez santiycr

💭
Always learning
View GitHub Profile
@santiycr
santiycr / selenium_test_case.py
Created July 26, 2011 19:24
Ignoring open failures as letting call selenium commands right from self, reporting pass/fail status automatically
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):
@santiycr
santiycr / implicit_wait_selenium.py
Created July 26, 2011 17:57
Implicit wait Selenium 1
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
@santiycr
santiycr / gist:1003731
Created June 2, 2011 01:12
Let Sauce know about your Selenium 1 python test results with 2 lines of code!
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()
@santiycr
santiycr / Tweet.java
Created March 11, 2011 23:15
Tweet about #SeleniumConf!
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");
@santiycr
santiycr / sauce_browsers_coordination.py
Created August 6, 2010 17:36
Coordinate multiple browsers in Sauce OnDemand using threads
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"