Skip to content

Instantly share code, notes, and snippets.

View freynaud's full-sized avatar

François Reynaud freynaud

  • Element34 Solutions GmbH
  • Altendorf, Switzerland
View GitHub Profile
private static void registerIOS(String nodehost, int port) throws JSONException, Exception {
RegistrationRequest node = new RegistrationRequest();
HttpClient client = new DefaultHttpClient();
String url = "http://" + nodehost + ":" + port + "/wd/hub/status";
BasicHttpRequest r = new BasicHttpRequest("GET", url);
HttpResponse response = client.execute(new HttpHost(nodehost, port), r);
public class Demo {
private final String hub = "http://localhost:4444/wd/hub";
@Test(invocationCount = 15, threadPoolSize = 2)
public void testIOSApp() {
UIADriver driver = new RemoteUIADriver(hub, IOSCapabilities.iphone("UICatalog"));
try {
Criteria c1 = new TypeCriteria(UIATableCell.class);
Criteria c2 = new NameCriteria("Buttons, Various uses of UIButton");
IOSCapabilities c = IOSCapabilities.iphone("InternationalMountains", "1.1");
c.setLanguage("fr");
...
NameCriteria criteria = new NameCriteria("sentenceFormat", L10NStrategy.serverL10N);
UIAElement text = driver.findElement(criteria);
String actual = text.getName();
var target = UIATarget.localTarget();
target.frontMostApp().mainWindow().tableViews()["Empty list"]
.cells()["Buttons, Various uses of UIButton"].tap();
target.frontMostApp().mainWindow().tableViews()["Empty list"]
.cells()["Background Image"].buttons()["Gray"].tap();
public enum WebDriverLikeCommand {
NEW_SESSION("POST","/session",String.class),
GET_SESSION("GET", "/session/:sessionId",JSONObject.class),
DELETE_SESSION("DELETE","/session/:sessionId",null),
SESSIONS("GET","/sessions",JSONArray.class),
SCREENSHOT("GET","/session/:sessionId/screenshot",Void.class),
ELEMENT("POST" , "/session/:sessionId/element/:id/element",UIAElement.class),
@DataProvider(name = "ipad")
public Object[][] getLanguages() {
return new Object[][] { {"en"}, {"fr"}, {"de"}};
}
@Test(dataProvider = "ipad")
public void testIOSAppIPAD(String language) {
IOSCapabilities cap = IOSCapabilities.ipad("eBay");
cap.setLanguage(language);
@freynaud
freynaud / xml
Created November 5, 2012 23:03
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>__argument</key>
<dict>
<key>WIRApplicationIdentifierKey</key>
<string>com.apple.mobilesafari</string>
<key>WIRConnectionIdentifierKey</key>
<string>95DF95FF-C8AF-4CF2-94E3-E940A7F03DA9</string>
public static void main(String[] args) throws IOException, InterruptedException, JSONException {
WebInspector inspector = new WebInspector();
JSONObject cmd = new JSONObject();
cmd.put("id", 1);
cmd.put("method", "Runtime.evaluate");
cmd.put(
"params",
new JSONObject().put("expression", "alert2('test');")
.put("objectGroup", "console")
public static void main(String[] args) throws Exception {
WebInspector inspector = new WebInspector();
String ref = inspector.findSearchButton();
inspector.callFunctionOn(ref);
}
{
"id": 3,
"result": {
"result": {
"subtype": "null",
"type": "object",
"value": null
},
"wasThrown": false
}