<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Anthony Long</title>
	<atom:link href="http://antlong.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://antlong.com</link>
	<description>Selenium, Python and more.</description>
	<lastBuildDate>Thu, 20 Oct 2011 18:29:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Headless JavaScript Testing with Python</title>
		<link>http://antlong.com/headless-javascript-testing-with-python/</link>
		<comments>http://antlong.com/headless-javascript-testing-with-python/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 15:14:33 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[QA]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[Test Automation]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[WebDriver]]></category>

		<guid isPermaLink="false">http://antlong.com/?p=275</guid>
		<description><![CDATA[There are many ways to test JavaScript, both the kind you find on a website, and local JavaScript as you would find in a Server-Side application like Node. While Selenium and WebDriver are good for this task, HTMLUnit does not always provide the results you expect. Here are some other Python based Headless JavaScript execution [...]]]></description>
			<content:encoded><![CDATA[<p>There are many ways to test JavaScript, both the kind you find on a website, and local JavaScript as you would find in a Server-Side application like Node. While Selenium and WebDriver are good for this task, HTMLUnit does not always provide the results you expect. Here are some other Python based Headless JavaScript execution frameworks.<br />
<span id="more-275"></span></p>
<ul>
<li><a href="http://code.google.com/p/spynner/" target="_blank">Spynner</a>: Spynner is a stateful programmatic web browser module for Python with Javascript/AJAX support based upon the QtWebKit framework.
</li>
<li><a href="http://splinter.cobrateam.info/" target="_blank">Splinter</a>: Splinter is an open source tool for testing web applications using Python. It lets you automate browser actions, such as visiting URLs and interacting with their items.
</li>
<li><a href="https://bitbucket.org/leapfrogdevelopment/punkybrowster/" target="_blank">PunkyBrowster</a>: PunkyBrowster is a programmatic browser with a synchronous API. It is a fork of the spynner project. We remove unessential stuff like URL filtering, download handling, and cookie emulation.
</li>
<p>All of the above require PyQt4 to be installed, which can be found here: http://www.riverbankcomputing.co.uk/software/pyqt/download</p>
<p>If you are on a Mac, you will probably have trouble getting this to work properly. You should install PySide instead: http://www.pyside.org/</p>
<p>Should you choose PySide over PyQt4 &#8211; be aware, you need to symlink PySide to where PyQt4 would be installed (Hint: Anywhere on your PYTHONPATH). When you create the symlink (ln -s path/to/PySide path/to/PyQt4) you also have to change an import &#8211; specifically the import QString. To make a long story short, QString was deprecated and removed from both PySide and PyQt4 and is still used in some third-party modules. When you encounter the QString error, modify the module like this:</p>
<pre class="brush: python; title: ; notranslate">
try:
    from PyQt4 import QString
except ImportError:
    QString = str
</pre>
<p>You are now all set.</p>
]]></content:encoded>
			<wfw:commentRss>http://antlong.com/headless-javascript-testing-with-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Admeld, (and I) acquired by Google</title>
		<link>http://antlong.com/admeld-and-myself-acquired-by-google/</link>
		<comments>http://antlong.com/admeld-and-myself-acquired-by-google/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 14:49:18 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[QA]]></category>
		<category><![CDATA[Reading]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[Test Automation]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://antlong.com/?p=272</guid>
		<description><![CDATA[As some of you may know, the company I work for was recently acquired by Google. This is great news for all involved, and is sure to be an experience to remember, and the beginning of a new chapter. If you are seeking help with Python and/or Selenium/Webdriver check out my meetup groups: http://meetup.com/Quality-Assurance http://meetup.com/Python-Testing [...]]]></description>
			<content:encoded><![CDATA[<p>As some of you may know, <a href="http://www.admeld.com/blog/view/admeld-acquired-by-google/">the company I work for was recently acquired by Google</a>. This is great news for all involved, and is sure to be an experience to remember, and the beginning of a new chapter.<br />
<span id="more-272"></span><br />
If you are seeking help with Python and/or Selenium/Webdriver check out my meetup groups:</p>
<p>http://meetup.com/Quality-Assurance</p>
<p>http://meetup.com/Python-Testing</p>
<p>http://meetup.com/PythonBrooklyn</p>
<p>For further reading on the acquisition, <a href="http://googleblog.blogspot.com/2011/06/helping-publishers-get-most-from.html">here is a post from the Google Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://antlong.com/admeld-and-myself-acquired-by-google/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run Currently Highlighted Test In py.test</title>
		<link>http://antlong.com/run-currently-highlighted-test-in-py-test/</link>
		<comments>http://antlong.com/run-currently-highlighted-test-in-py-test/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 18:13:04 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[QA]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Test Automation]]></category>
		<category><![CDATA[TextMate]]></category>

		<guid isPermaLink="false">http://antlong.com/?p=246</guid>
		<description><![CDATA[I don&#8217;t like switching from my text editor to terminal, so I created a TextMate snippet that will run the currently highlighted test in py.test. As a bonus, it will also stop TextMate from opening a new terminal window. Pytest Current Function.tmCommand To install: Uncompress Double-Click the uncompressed file Highlight word (or place your cursor [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t like switching from my text editor to terminal, so I created a TextMate snippet that will run the currently highlighted test in py.test.<br />
<span id="more-246"></span><br />
As a bonus, it will also stop TextMate from opening a new terminal window.<br />
<a href='http://antlong.com/wp-content/uploads/2011/01/Pytest-Current-Function.tmCommand.zip'>Pytest Current Function.tmCommand</a><br />
To install:<br />
Uncompress<br />
Double-Click the uncompressed file<br />
Highlight word (or place your cursor on any part of it)<br />
Press Command + R<br />
[Note, you must have a terminal window open for it to not create a new one]</p>
]]></content:encoded>
			<wfw:commentRss>http://antlong.com/run-currently-highlighted-test-in-py-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TextMate &#8211; Run Script in Existing Terminal Window</title>
		<link>http://antlong.com/textmate-run-script-in-existing-terminal-window/</link>
		<comments>http://antlong.com/textmate-run-script-in-existing-terminal-window/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 20:55:05 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[TextMate]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://antlong.com/?p=242</guid>
		<description><![CDATA[For a long time I wondered if it was possible to run scripts in a pre-existing terminal window, when using &#8216;Run Script in Terminal&#8217; through TextMate. Well, I finally figured it out, and it was a lot easier than I had thought.]]></description>
			<content:encoded><![CDATA[<p>For a long time I wondered if it was possible to run scripts in a pre-existing terminal window<br /><span id="more-242"></span>, when using &#8216;Run Script in Terminal&#8217; through TextMate. Well, I finally figured it out, and it was a lot easier than I had thought.</p>
<pre class="brush: python; title: ; notranslate">
osascript &lt;&lt;- APPLESCRIPT
	tell application &quot;System Events&quot;
		if (count (processes whose name is &quot;Terminal&quot;)) is greater than 0 then
			tell application &quot;Terminal&quot;
			do script &quot;clear; cd $(esc &quot;${TM_DIRECTORY}&quot;); $(esc &quot;${TPY}&quot;) $(esc &quot;${TM_FILEPATH}&quot;); rm -f $(esc &quot;${TM_TMPFILE}&quot;)&quot; in window 1
			end tell
		else
			tell application &quot;Terminal&quot;
			do script &quot;clear; cd $(esc &quot;${TM_DIRECTORY}&quot;); $(esc &quot;${TPY}&quot;) $(esc &quot;${TM_FILEPATH}&quot;); rm -f $(esc &quot;${TM_TMPFILE}&quot;)&quot;
			end tell
		end if
	end tell
APPLESCRIPT
</pre>
]]></content:encoded>
			<wfw:commentRss>http://antlong.com/textmate-run-script-in-existing-terminal-window/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selenium-Python Textmate Bundle</title>
		<link>http://antlong.com/selenium-python-textmate-bundle/</link>
		<comments>http://antlong.com/selenium-python-textmate-bundle/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 17:54:22 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[TextMate]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://antlong.com/?p=237</guid>
		<description><![CDATA[Get it on github.]]></description>
			<content:encoded><![CDATA[<p><a href="http://github.com/antlong/Selenium-Python.tmbundle">Get it on github.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://antlong.com/selenium-python-textmate-bundle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run Selenium Cases Through A Web Interface</title>
		<link>http://antlong.com/run-selenium-cases-through-a-web-interface/</link>
		<comments>http://antlong.com/run-selenium-cases-through-a-web-interface/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 15:07:28 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[QA]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Test Automation]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://antlong.com/?p=232</guid>
		<description><![CDATA[I&#8217;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. I do not recommend this. Some cases can take over 30-60 seconds to run, and would cause the browser to time out before it finished, which would render the case, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;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.</p>
<p><span id="more-232"></span></p>
<p>I do not recommend this. Some cases can take over 30-60 seconds to run, and would cause the browser to time out before it finished, which would render the case, and this mechanism useless.</p>
<p>However if you still want to give this a shot, here is some sample code to get you started.</p>
<pre class="brush: python; title: ; notranslate">
from selenium import selenium
from flask import Flask
from flask import render_template
import unittest
SERVER_SETUP = [&quot;ip_for_selenium_server&quot;, 4444, &quot;*firefox&quot;, &quot;your_base_url&quot;]

app = Flask(__name__)

@app.route(&quot;/&quot;)
def index():
    return render_template('template.html', name='index')

@app.route(&quot;/Test_1/&quot;)
def test_1():
    selenium.selenium = selenium(*SERVER_SETUP)
    selenium.selenium.start()
    selenium.selenium.open(&quot;http://example.com/&quot;)
    selenium.selenium.click(&quot;link=ishjdf&quot;)

if __name__ == &quot;__main__&quot;:
    app.run(debug=True)
</pre>
<p>Everything in the above script should be obvious. The cool part about app.run() is it has debug=True, which will restart the server whenever you edit and save the code.</p>
<p>Here is the template.html.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;style&gt;
body{ font-size: 12px; font-family: Arial; }
&lt;/style&gt;
&lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;b&gt;&lt;h1&gt;Some Text Here&lt;/b&gt;&lt;/h1&gt;
&lt;script&gt;
function test(url) {
	alert(url);
   $('#result').load(url);
}
$(document).ready(function() {
   $(&quot;a&quot;).click(function(e) {
       e.preventDefault();
       var url = $(this).attr(&quot;href&quot;);
       test(url);
   });
});
&lt;/script&gt;

&lt;a href=&quot;/Test_1/&quot;&gt;Perform Test 1&lt;/a&gt;
&lt;div id=&quot;result&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Add this inside a folder within your root,  called templates/. You should have root/ and root/templates.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://antlong.com/run-selenium-cases-through-a-web-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nose print bug fixed</title>
		<link>http://antlong.com/nose-print-bug-fixed/</link>
		<comments>http://antlong.com/nose-print-bug-fixed/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 03:55:43 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://antlong.com/?p=220</guid>
		<description><![CDATA[I fixed the nose print bug, where the first run of a test with a print statement would pass but any run thereafter would fail. Get the fix here: http://github.com/antlong/nose If you see this error, then you need to checkout my fix: The fix lies in editing capture.py to remove the two commented items from [...]]]></description>
			<content:encoded><![CDATA[<p>I fixed the nose print bug, where the first run of a test with a print statement would pass but any run thereafter would fail.</p>
<p>Get the fix here:</p>
<p>http://github.com/antlong/nose</p>
<p><span id="more-220"></span></p>
<p>If you see this error, then you need to checkout my fix:</p>
<p>ERROR: test.test<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Traceback (most recent call last):<br />
  File &quot;/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/nose/case.py&quot;, line 188, in runTest<br />
    test(*self.arg)<br />
  File &quot;/Users/along/Desktop/nosetest/test.py&quot;, line 2, in test<br />
    print(&quot;hello&quot;)<br />
  File &quot;/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/StringIO.py&quot;, line 213, in write<br />
    _complain_ifclosed(self.closed)<br />
TypeError: &#8216;NoneType&#8217; object is not callable</p>
<p>The fix lies in editing capture.py to remove the two commented items from start()</p>
<pre class="brush: python; title: ; notranslate">
    def formatError(self, test, err):
        &quot;&quot;&quot;Add captured output to error report.
        &quot;&quot;&quot;
        test.capturedOutput = output = self.buffer
        #COMMENT THIS LINE BELOW
        #self._buf = None
        if not output:
            # Don't return None as that will prevent other
            # formatters from formatting and remove earlier formatters
            # formats, instead return the err we got
            return err
        ec, ev, tb = err
        return (ec, self.addCaptureToErr(ev, output), tb)
</pre>
<p>Also for good measure, change<br />
from StringIO import StringIO<br />
to<br />
from cStringIO import StringIO</p>
]]></content:encoded>
			<wfw:commentRss>http://antlong.com/nose-print-bug-fixed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python Credit Card Generator</title>
		<link>http://antlong.com/python-credit-card-generator/</link>
		<comments>http://antlong.com/python-credit-card-generator/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 20:07:01 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://antlong.com/?p=218</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: python; title: ; notranslate">
from random import Random
import copy
generator = Random()
generator.seed()

def creditcard(type=&quot;&quot;):
        def credit_card_number(generator, prefixList, length):
            def _completed_number(prefix, length):
                ccnumber = prefix
                while len(ccnumber) &lt; (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 &lt; length - 1:
                    odd = int( reversedCCnumber[pos] ) * 2
                    if odd &gt; 9:
                        odd -= 9
                    sum += odd
                    if pos != (length - 2):
                        sum += int( reversedCCnumber[pos+1] )
                    pos += 2
                checkdigit = ((sum / 10 + 1) * 10 - sum) % 10
                ccnumber.append( str(checkdigit) )
                return ''.join(ccnumber)
            result = []
            ccnumber = copy.copy( generator.choice(prefixList) )
            result.append( _completed_number(ccnumber, length) )
            return result

        if type in &quot;visa&quot;:
            visaPrefixList = [['4','0','2','4', '0', '0', '7', '1'],]
            return credit_card_number(generator, visaPrefixList, 16)
        elif type is &quot;amex&quot;:
            amexPrefixList = [['3','4'],['3', '7']]
            return credit_card_number(generator, amexPrefixList, 16)
        elif type is &quot;discover&quot;:
            discoverPrefixList = [['6','0','1','1']]
            return credit_card_number(generator, discoverPrefixList, 16)
        elif type is &quot;mastercard&quot;:
            mastercardPrefixList = [['5','1'],['5','2'],['5','3'],['5','4'],['5','5']]
            return credit_card_number(generator, mastercardPrefixList, 16)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://antlong.com/python-credit-card-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run concurrent processes</title>
		<link>http://antlong.com/run-concurrent-processes/</link>
		<comments>http://antlong.com/run-concurrent-processes/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 15:37:24 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://antlong.com/?p=216</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: python; title: ; notranslate">
import signal
import subprocess, os

signal.alarm(5)

def oh_crap(*args):
    def _inner(*a):
        for pid in args:
            print &quot;Killing %d&quot; % pid
            os.kill(pid, signal.SIGKILL)
    return _inner

p1 = subprocess.Popen([&quot;/usr/bin/python&quot;, &quot;alarmer.py&quot;])
p2 = subprocess.Popen([&quot;/usr/bin/python&quot;, &quot;alarmer.py&quot;])

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 &quot;Done.&quot;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://antlong.com/run-concurrent-processes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Giant List of Data Models</title>
		<link>http://antlong.com/giant-list-of-data-models/</link>
		<comments>http://antlong.com/giant-list-of-data-models/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 20:02:28 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[Data Models]]></category>

		<guid isPermaLink="false">http://antlong.com/?p=212</guid>
		<description><![CDATA[I was searching for a list of common data models for picka. What I came across was this monster listing. http://www.databaseanswers.org/data_models/]]></description>
			<content:encoded><![CDATA[<p>I was searching for a list of common data models for picka. What I came across was this monster listing.</p>
<p><span id="more-212"></span></p>
<p><a href="http://www.databaseanswers.org/data_models/">http://www.databaseanswers.org/data_models/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://antlong.com/giant-list-of-data-models/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

