Skip to content

Instantly share code, notes, and snippets.

@jleyba
jleyba / gist:1265280
Created October 5, 2011 18:39
OperaDriver failures
11:39:11.172 INFO - Executing: [new session: {platform=ANY, browserName=opera, version=}] at URL: /session)
11:39:11.172 INFO - Executing: [new session: {platform=ANY, browserName=opera, version=}] at URL: /session)
11:39:14.275 ERROR - Error : service: "exec"
commandID: 2
format: 0
status: 8
tag: 9
payload: "\n\026Service is not enabled"
11:39:14.277 WARN - Got exception
@jleyba
jleyba / gist:1265931
Created October 5, 2011 22:26
String memory leak
public String getFileSnippet(File f) {
String contents = readFileToString(f);
return contents.substring(0, 20);
}
@jleyba
jleyba / gist:1265942
Created October 5, 2011 22:31
test_opera failures
Testsuite: org.openqa.selenium.opera.OperaDriverTestSuite
Tests run: 0, Failures: 1, Errors: 0, Time elapsed: 6.764 sec
------------- Standard Error -----------------
Ignoring test class: class org.openqa.selenium.AlertsTest: Not implemented in driver yet
Ignoring test class: class org.openqa.selenium.ClearTest: Not implemented in driver yet
Ignoring: class org.openqa.selenium.ClickTest.testCanClickOnALinkThatOverflowsAndFollowIt: Not tested on these browsers.
Ignoring: class org.openqa.selenium.ClickTest.testCanClickOnALinkThatUpdatesAnotherFrame: iPhone: Frame switching is unsupportedOpera: Incorrect runtime retrieved, Android: A bug in emulator JSC egine on 2.2, works on devices.
Ignoring: class org.openqa.selenium.ClickTest.testElementsFoundByJsCanLoadUpdatesInAnotherFrame: iPhone: Frame switching is unsupportedOpera: Incorrect runtime retrieved, Android: fails when running with other tests.
Ignoring: class org.openqa.selenium.ClickTest.testJsLoactedElementsCanUpdateFramesIfFoundSomehowElse: iPhone: Frame
@jleyba
jleyba / gist:1279579
Created October 11, 2011 21:55
WebDriverJS
// Letting webdriver.promise.Application synchronize everything for you.
// Each line queues a task for execution.
// This is easy to read, not so easy to debug :(
var driver = new webdriver.Builder().build();
driver.get('http://www.google.com');
driver.findElement(By.name('q')).sendKeys('webdriver');
driver.findElement(By.name('btnG')).click();
assertThat(driver.getTitle(), equals('webdriver - Google Search'));
@jleyba
jleyba / gist:2510814
Created April 27, 2012 17:01
Suggestion for using atoms with phantomjs
/*
DISCLAIMER: I've not used phantomjs or ghost driver, so I'm not familiar with the APIs.
*/
// Assumes this is the //javascript/webdriver/atoms/inject:find_element fragment. It is
// an anonymous function ready for injection into the page.
var findElement = require('./webdriver_atoms.js').get('findElement');
// Inject findElement into the page.
#This is the addition to $/javascript/webdriver/atoms/build.desc to build the compiled JavaScript
js_fragment(name = "sendKeys",
module = "webdriver.atoms.inputs",
function = "webdriver.atoms.inputs.sendKeys",
deps = [ ":deps" ])
@jleyba
jleyba / gist:2560587
Created April 30, 2012 18:15
Google Search with atoms
// Copy and paste this into the console for http://www.google.com
// Generated from //javascript/webdriver/atoms/inject:find_element
var findElement = function(){return function(){function i(a){throw a;}var j=void 0,k=!0,l=null,m=!1,n=this;
function o(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function aa(a){var b=o(a);return"array"==b||"object"==b&&"number"==typeof a.length}function q(a){return"string"==typeof a}function r(a){return"function"==o(a)}function
// copy+paste isDisplayed definition into console
var e = document.querySelector('input[name=username]')
isDisplayed(e);
ChromeOptions options = new ChromeOptions();
options.addArguments("user-agent=foo;bar");
WebDriver driver = new ChromeDriver(options);
driver.get("http://www.google.com");
String userAgent = ((JavascriptExecutor) driver).executeScript("return window.navigator.userAgent");
System.out.println(userAgent);
webdriver.atoms.inject.dom.getText = function(element, opt_window) {
var response;
try {
var targetWindow = webdriver.atoms.inject.getWindow(opt_window);
var domEl = /** @type {!Element} */ (bot.inject.cache.getElement(
element[bot.inject.ELEMENT_KEY], targetWindow.document));
var text = bot.dom.getVisibleText(domEl);
response = bot.inject.wrapResponse(text);
} catch (ex) {
response = bot.inject.wrapError(ex);