Created
November 10, 2010 15:18
-
-
Save dmachi/670973 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var session = new Session({url: "http://192.168.5.16:4444/wd/hub"}) | |
var capabilities = session.startSession({browserName: "internet explorer"}); | |
var url = "http://google.com"; | |
when(capabilities,function(capabilities){ | |
print("Connected to Session"); | |
print("sessionId: " + capabilities.sessionId); | |
print("Session Props: " + json.stringify(capabilities)); | |
pshallow(capabilities); | |
print("get...", url); | |
var nav = session.get(url); | |
/* | |
nav.then(function(){ | |
return when(session.getCurrentUrl(), function(u){ | |
print("CurrentUrl: " + u.value); | |
}) | |
}); | |
*/ | |
/* | |
nav.then(function(){ | |
return when(session.getScreenshot("BASE64"), function(img){ | |
print("Base64 Screenshot length: " + img.value.length); | |
}) | |
}); | |
*/ | |
nav.then(function(){ | |
return when(session.findElement(by.linkText("Make Google my homepage")), function(element){ | |
var el = element; | |
el.describe().then(function(response){ | |
print("describe(): " + json.stringify(response.value)); | |
}); | |
el.getInnerText().then(function(response){ | |
print("innerText: " + json.stringify(response.value)); | |
}); | |
el.getTagName().then(function(response){ | |
print("tagName: " + json.stringify(response.value)); | |
}); | |
el.click(); | |
}); | |
}); | |
/* | |
nav.then(function(){ | |
return when(session.findElements(by.tagName("a")), function(elements){ | |
elements.forEach(function(el){ | |
print("Got <a> element: ", el); | |
}) | |
}); | |
}); | |
*/ | |
/* | |
nav.then(function(){ | |
print("Execute script..."); | |
return when(session.executeScript('(function(w){return {foo: "bar"}})()'),function(execResults){ | |
print(" - type of result: " + typeof execResults); | |
print(execResults.foo); | |
},function(err){ | |
print("Unable to execute script: " + err); | |
return err; | |
}); | |
}); | |
*/ | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment