Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<style>
html { background: silver; }
body { background: blue; }
div { background: red; }
</style>
<body>
<div style="width=100px;">Hello!</div>
</body>
driver.get("https://www.betxchange.co.za/");
driver.wait(function() {
return driver.isElementPresent({id: "enterHyperLink"}).then(function(present) {
if (!present) return false;
return driver.findElement({id: "enterHyperLink"}).isDisplayed();
});
}, 5000).then(function() {
console.log('found it');
}, function(err) {
console.log(err.stack);
@jleyba
jleyba / multiflow.js
Last active August 29, 2015 14:02
"Parallel" WebDriver sessions
var webdriver = require('selenium-webdriver');
var results = [];
for (var i = 0; i < 3; ++i) {
results.push(webdriver.promise.createFlow(function() {
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
driver.get('http://www.google.com');
interface NetworkConnection {
Type getConnection();
void setConnection(Type type);
enum Type {
WIFI,
CELLULAR,
NONE
}
}
T 2014-04-03 16:18:18:935 IECommandExecutor.cpp(162) Entering IECommandExecutor::OnExecCommand
T 2014-04-03 16:18:18:935 IECommandExecutor.cpp(453) Entering IECommandExecutor::DispatchCommand
T 2014-04-03 16:18:18:935 IECommandExecutor.cpp(569) Entering IECommandExecutor::GetCurrentBrowser
T 2014-04-03 16:18:18:935 IECommandExecutor.cpp(575) Entering IECommandExecutor::GetManagedBrowser
T 2014-04-03 16:18:18:935 IECommandExecutor.cpp(525) Entering IECommandExecutor::IsAlertActive
T 2014-04-03 16:18:18:935 Browser.cpp(631) Entering Browser::GetActiveDialogWindowHandle
T 2014-04-03 16:18:18:935 Browser.cpp(175) Entering Browser::GetWindowHandle
D 2014-04-03 16:18:18:935 IECommandExecutor.cpp(539) No alert handle is found
T 2014-04-03 16:18:18:935 IECommandExecutor.cpp(569) Entering IECommandExecutor::GetCurrentBrowser
T 2014-04-03 16:18:18:935 IECommandExecutor.cpp(575) Entering IECommandExecutor::GetManagedBrowser
// class FirefoxOptions extends Options {};
FirefoxOptions options = new FirefoxOptions();
options.setEnableNativeEvents(true);
options.setProxy(proxy);
options.setProfile(new FirefoxProfile());
options.set("customKey", "customValue");
WebDriver driver = new FirefoxDriver(options);
bot.inject.recompileFunction_ = function(fn, theWindow) {
if (goog.isString(fn)) {
try {
return new theWindow['Function'](fn);
} catch (ex) {
// Try to recover if in IE-quirks.
if (theWindow.execScript) {
theWindow.execScript('var __$$webdriver_fn$$__ = (function(){' + fn + '\n})');
return theWindow['__$$webdriver_fn$$__'];
}
log4j:ERROR setFile(null,false) call failed.
java.io.FileNotFoundException: log.txt (Permission denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
at java.io.FileOutputStream.<init>(FileOutputStream.java:136)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:290)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:164)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:257)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:133)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:97)
@jleyba
jleyba / gist:6939136
Created October 11, 2013 17:53
Add logging using Closure. Logged messages will be printed to the DOM.
goog.require('goog.debug.DivConsole');
goog.require('goog.debug.LogManager');
goog.require('goog.log');
var div = document.createElement('div');
document.body.appendChild(div);
var divConsole = new goog.debug.DivConsole(div);
divConsole.setCapturing(true);
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);