first commit
This commit is contained in:
13
code/2-session/index.html
Normal file
13
code/2-session/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title> WebDiver testpage</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body>
|
||||
<h1>This is a WebDiver testpage</h1>
|
||||
<script src="webdriver.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
30
code/2-session/webdriver.js
Normal file
30
code/2-session/webdriver.js
Normal file
@@ -0,0 +1,30 @@
|
||||
var getSession = function (cb) {
|
||||
var request = new XMLHttpRequest();
|
||||
request.open('POST', 'http://localhost:7020/session', true);
|
||||
request.setRequestHeader('Content-Type', 'application/json');
|
||||
|
||||
request.onload = function() {
|
||||
cb(null, JSON.parse(request.responseText));
|
||||
};
|
||||
|
||||
request.onerror = function() {
|
||||
cb(arguments, null);
|
||||
};
|
||||
|
||||
request.send(JSON.stringify({
|
||||
desiredCapabilities: {
|
||||
browserName: 'phantomjs',
|
||||
version: '',
|
||||
platform: 'ANY'
|
||||
}
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
getSession(function (err, data) {
|
||||
var el = document.createElement('div');
|
||||
var contents = document.createTextNode(JSON.stringify(data));
|
||||
el.appendChild(contents);
|
||||
document.getElementsByTagName('body')[0].appendChild(el);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user