Archive for the ‘Snippets’ Category

July 28, 2010 0

Run Selenium Cases Through A Web Interface

By Anthony in Python, QA, Selenium, Snippets, Test Automation, Testing

I’ve heard a couple of people ask how to run Selenium test cases through a web interface with python. Here is how you do it.

July 20, 2010 0

Python Credit Card Generator

By Anthony in Snippets

from random import Random import copy generator = Random() generator.seed() def creditcard(type=""): def credit_card_number(generator, prefixList, length): def _completed_number(prefix, length): ccnumber = prefix while len(ccnumber) < (length – 1): digit = generator.choice(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']) ccnumber.append(digit) sum, pos = (0, 0) reversedCCnumber = [] reversedCCnumber.extend(ccnumber) reversedCCnumber.reverse() while pos < length [...]

July 20, 2010 0

Run concurrent processes

By Anthony in Snippets

import signal import subprocess, os signal.alarm(5) def oh_crap(*args): def _inner(*a): for pid in args: print "Killing %d" % pid os.kill(pid, signal.SIGKILL) return _inner p1 = subprocess.Popen(["/usr/bin/python", "alarmer.py"]) p2 = subprocess.Popen(["/usr/bin/python", "alarmer.py"]) signal.signal(signal.SIGALRM, oh_crap(p1.pid, p2.pid)) pid, sts = os.waitpid(p1.pid, 0) pid, sts = os.waitpid(p2.pid, 0) print "Done."

July 16, 2010 0

Twitter your build status with Twildbot.

By Anthony in Python, QA, Snippets

This is a tiny script which will get the current status of your build, and tweet it to your twitter account.

July 15, 2010 0

Adding JQuery Locators to Selenium

By Anthony in Selenium, Snippets, Test Automation, Testing

It’s very simple to add jquery functionality to your selenium installation, and also very useful if you use the functions a lot.

July 13, 2010 0

iTunes: One key song deletion.

By Anthony in Snippets

This AppleScript snippet will allow you to assign a key to instantly move the currently playing song to your trash. To set this, put it in ~/Library/iTunes/Scripts then assign the hotkey via System Preferences. global addenda tell application "iTunes" if player state is not stopped then set ofi to fixed indexing set fixed indexing to [...]