Skip to content

Instantly share code, notes, and snippets.

View AutomatedTester's full-sized avatar
😃
Happy to help!

David Burns AutomatedTester

😃
Happy to help!
View GitHub Profile
@AutomatedTester
AutomatedTester / .travis.yml
Created November 10, 2011 11:23
.travis.yml
language: node_js
node_js:
- 0.4
env:
- DB=mongo
- DB=redis
notifications:
email:
- powerball@theautomatedtester.co.uk
@AutomatedTester
AutomatedTester / test_firefox.py
Created November 16, 2011 23:53
python leaving Firefox open
from selenium import webdriver
def main():
f = webdriver.Firefox()
f.get("http://www.theautomatedtester.co.uk")
if __name__ == "__main__":
main()
@AutomatedTester
AutomatedTester / output from mocha
Created November 25, 2011 22:31
When a method fails only the test runner is shown in the stack trace
..
✖ 2 of 2 tests failed:
0) test failure should give meaningful data:
TypeError: Cannot set property 'failed' of undefined
at Runner.fail (/usr/local/lib/node_modules/mocha/lib/runner.js:90:15)
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:294:12)
@AutomatedTester
AutomatedTester / Driver.java
Created December 1, 2011 10:08
Fennec Native Testing using a WebDriver-esque API
package org.mozilla.fennec;
public interface Driver {
/**
* Find the first Element using the given method.
*
* @param by The locating mechanism
* @return The first matching element on the current context
* @throws RoboCopException If no matching elements are found
*/
@AutomatedTester
AutomatedTester / mochafailure.js
Created December 5, 2011 20:48
message isnt really relevant for a failure
var assert = require('assert');
describe('a mocha test', function(){
it('should not hang when it fails', function(done){
assert.ok(1 == 2);
done()
});
});
@AutomatedTester
AutomatedTester / mochaHang.js
Created December 5, 2011 21:11
This will cause a test to hang because the assert fails
// create an express app, doesn't really matter whats in the app
var assert = require('assert')
, http = require('http')
, server = require('../app');
describe('mocha test', function(){
it('should hang because this wont be in the app', function(done){
http.get({ path: '/user/omgthiswontexist', port: 3000 }, function(res){
assert.ok(res.statusCode === 404);
davidburns :: ~/mocha> mocha mocha.js
.
✖ 1 of 1 tests failed:
0) a mocha test should not hang when it fails:
ssertionError: false == true
at Test.fn (/Users/davidburns/mocha/mocha.js:5:12)
@AutomatedTester
AutomatedTester / screenshotexample.py
Created January 17, 2012 23:20
This will load Firefox and take a screenshot and then
from optparse import OptionParser
from selenium import webdriver
def main(url):
driver = webdriver.Firefox()
driver.get(url)
driver.save_screenshot("file.png")
driver.quit()
if __name__=="__main__":
(foogar)davidburns :: /development/temp> har mysite.har
/Library/Ruby/Site/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find rake (>= 0.8.1) amongst [addressable-2.2.6, configuration-1.2.0, foreman-0.18.0, har-0.0.8, heroku-2.2.4, json-1.4.6, json-schema-0.1.12, launchy-0.4.0, mime-types-1.16, rest-client-1.6.1, rubygems-update-1.8.5, rubygems-update-1.4.2, term-ansicolor-1.0.5, thor-0.14.6, vimgolf-0.3.0] (Gem::LoadError)
from /Library/Ruby/Site/1.8/rubygems/specification.rb:759:in `activate_dependencies'
from /Library/Ruby/Site/1.8/rubygems/specification.rb:756:in `each'
from /Library/Ruby/Site/1.8/rubygems/specification.rb:756:in `activate_dependencies'
from /Library/Ruby/Site/1.8/rubygems/specification.rb:741:in `activate'
from /Library/Ruby/Site/1.8/rubygems/specification.rb:762:in `activate_dependencies'
from /Library/Ruby/Site/1.8/rubygems/specification.rb:756:in `each'
from /Library/Ruby/Site/1.8/rubygems/specification.rb:756:in `activate_dependencies'
from /Library/Ruby/Site/1.
@AutomatedTester
AutomatedTester / gist:1676185
Created January 25, 2012 13:09
Click Errors
<?xml version="1.0" encoding="utf-8"?><testsuite name="" errors="0" failures="82" skips="15" tests="336" time="161.912" >
<testcase classname="build.lib.selenium.test.selenium.webdriver.firefox.ff_alerts_tests.FirefoxAlertsTest" name="testAlertShouldNotAllowAdditionalCommandsIfDimissed" time="0"><failure message="test failure">self = &lt;selenium.test.selenium.webdriver.firefox.ff_alerts_tests.FirefoxAlertsTest testMethod=testAlertShouldNotAllowAdditionalCommandsIfDimissed&gt;
@pytest.mark.ignore_chrome
def testAlertShouldNotAllowAdditionalCommandsIfDimissed(self):
self._loadPage(&quot;alerts&quot;);
&gt; self.driver.find_element(By.ID, &quot;alert&quot;).click()
build/lib/selenium/test/selenium/webdriver/common/alerts_tests.py:103:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _