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.
Archive for the ‘Snippets’ Category
Run Selenium Cases Through A Web Interface
By Anthony in Python, QA, Selenium, Snippets, Test Automation, TestingPython Credit Card Generator
By Anthony in Snippetsfrom 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 [...]
Run concurrent processes
By Anthony in Snippetsimport 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."
Twitter your build status with Twildbot.
By Anthony in Python, QA, SnippetsThis is a tiny script which will get the current status of your build, and tweet it to your twitter account.
Adding JQuery Locators to Selenium
By Anthony in Selenium, Snippets, Test Automation, TestingIt’s very simple to add jquery functionality to your selenium installation, and also very useful if you use the functions a lot.
iTunes: One key song deletion.
By Anthony in SnippetsThis 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 [...]


