Skip to content

Instantly share code, notes, and snippets.

@nicegraham
nicegraham / TouchAction.java
Created August 16, 2012 12:26
Dynamically load jquery for TouchActions
package com.paddypower.selenium.framework;
import com.paddypower.reporter.ReporterFactory;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import java.io.IOException;
import java.io.InputStream;
public class TouchAction {
@nicegraham
nicegraham / DriverFactory.java
Created December 3, 2012 09:46
Running JBehave in parallel
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.URL;
import java.util.concurrent.TimeUnit;
public final class DriverFactory {
private RemoteWebDriver remoteWebDriver = null;
@nicegraham
nicegraham / DebugGrid.java
Last active December 15, 2015 18:19
debug grid
package org.uiautomation.ios.grid;
import org.openqa.grid.selenium.GridLauncher;
public class DebugGrid {
public static void main(String[] args) throws Exception {
String[] a = {"-port", "4444",
"-capabilityMatcher", "org.uiautomation.ios.grid.IOSCapabilityMatcher",
"-role", "hub"};
@nicegraham
nicegraham / gist:5304406
Created April 3, 2013 19:21
ios-driver faq
Troubleshooting configuration issues:
1) MobileSafari.app/Info.plist (Permission denied)
error starting instrument for session XXX, Cannot change the default device for the app.
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/
iPhoneSimulator6.0.sdk/Applications/MobileSafari.app/Info.plist (Permission denied)
Safari's Info.plist file contains the device family safari can be launched on.
It looks like : "UIDeviceFamily":[1,2]
1 is for iphone. 2 is for ipad.
IOSCapabilities cap = IOSCapabilities.iphone("InternationalMountains", "1.1");
cap.setCapability(IOSCapabilities.SIMULATOR, false);
cap.setCapability(IOSCapabilities.DEVICE, DeviceType.iphone);
RemoteIOSDriver driver = new RemoteIOSDriver(new URL("http://localhost:5555/wd/hub"), cap);
driver.logElementTree(new File("test.png"), false);
String name = "PP_Login";
String value = customer.getToken();
String domain = Utils.getAppServer();
String path = "/";
Cookie cookie = new Cookie(name, value, domain, path, null);
driver.manage().addCookie(cookie);
driver.navigate().refresh();
public class BasicTest {
private MacSessionFactory session;
private PPCustomer customer;
//Basic Tests Before Test Setup
@BeforeTest
public void beforeTest() {
//get the rack details [db, urls etc] we're connecting to
RackDataFactory.getRackDataFactory().init(getRackDataFromDb("qa1"));
@nicegraham
nicegraham / GridInfo.java
Created June 21, 2013 15:34
get the node information for a given host and session
package com.paddypower.automation.selenium.framework;
import com.paddypower.automation.reporter.MessageType;
import org.json.JSONException;
import org.json.JSONObject;
import java.net.MalformedURLException;
import java.net.URL;
import static com.paddypower.automation.selenium.reporter.SeleniumReporterFactory.getSeleniumReporter;
package com.paddypower.ecommerce.grid.servlets;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.openqa.grid.common.exception.GridException;
import org.openqa.grid.internal.ProxySet;
import org.openqa.grid.internal.Registry;
import org.openqa.grid.internal.RemoteProxy;
import org.openqa.grid.web.servlet.RegistryBasedServlet;
@nicegraham
nicegraham / gist:5875155
Created June 27, 2013 09:22
maven ouput for the rspec tests mvn test -e -X
[INFO]
[INFO] --- rspec-maven-plugin:1.0:spec (test) @ SeleniumGridExtras ---
[DEBUG] org.codehaus.mojo:rspec-maven-plugin:jar:1.0:
[DEBUG] org.apache.maven:maven-plugin-api:jar:2.0:compile
[DEBUG] org.jruby:jruby-complete:jar:1.6.7:compile
[DEBUG] org.codehaus.plexus:plexus-utils:jar:1.1:runtime
[DEBUG] Created new class realm plugin>org.codehaus.mojo:rspec-maven-plugin:1.0
[DEBUG] Importing foreign packages into class realm plugin>org.codehaus.mojo:rspec-maven-plugin:1.0
[DEBUG] Imported: < maven.api
[DEBUG] Populating class realm plugin>org.codehaus.mojo:rspec-maven-plugin:1.0