source: Dev/trunk/src/client/util/doh/plugins/android-webdriver-robot.html @ 529

Last change on this file since 529 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 3.9 KB
Line 
1<!DOCTYPE html>
2<html>
3<head>
4<script type="text/javascript" src="../../../dojo/dojo.js"
5                data-dojo-config="isDebug: true, async: true, parseOnLoad: true"></script>
6<link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/claro/claro.css"/>
7<script>
8onSubmit1 = null;
9onSubmit2 = null;
10require(["dojo/dom", "dojo/_base/xhr", "dijit/form/Form", "dijit/form/Button", "dojo/parser", "dijit/registry"], function(dom, xhr, Form, Button, parser, registry){
11        var baseURL=null;
12        onSubmit1 = function(){
13                baseURL = "http://"+dom.byId('baseIP').value+":8080/wd/hub";
14                var status = dom.byId('status');
15                var message = dom.byId('message');
16                var sessionId = null;
17                // WebDriver sends a 302 to the new test session.
18                // Sadly, the browser tries to follow it automatically, so the xhr will always throw an error.
19                xhr("POST",{
20                        url:baseURL+"/session",
21                        headers: { "Content-Type": "application/json"},
22                        handleAs:"json",
23                        postData:'{desiredCapabilities:{"nativeEvents": "true", "browserName":"android",platform:"ANDROID","version":"","browserConnectionEnabled":"true","javascriptEnabled":"true"}}',
24                        load:function(json){
25                                // didn't expect a JSON response...
26                                console.log(json);
27                        },
28                        error:function(e,ioArgs){
29                                console.log(msg);
30                                status.innerHTML = "Check network tab to get session ID.";
31                        }
32                });
33                return false;
34        };
35        onSubmit2 = function(){
36                // expected result: couldn't load new address
37                // instead, issue new POST to load test in session
38                var testURL = dom.byId('testURL').value;
39                var status = dom.byId('status');
40                var message = dom.byId('message');
41                sessionId = dom.byId('sessionID').value;
42                dojo.xhr("POST",{
43                        url:baseURL+"/session/"+sessionId+"/url",
44                        headers: { "Content-Type": "application/json"},
45                        handleAs:"json",
46                        postData:'{url:"'+testURL+'&remoteRobotURL=http://localhost:8080/wd/hub/session/'+sessionId+'"}',
47                        load:function(msg){
48                                console.log(msg);
49                                status.innerHTML = "Test started";
50                                message.innerHTML = msg;
51                        },
52                        error:function(e){
53                                status.innerHTML = "Test did not start";
54                                message.innerHTML = e;
55                        }
56                });
57        };
58});
59</script>
60</head>
61<body class="claro">
62<p>This is a prototype tool to assist starting a DOH test on an Android WebDriver. The goal is to automate this process into just one form submit.</p>
63<p>To start a test:</p>
64<ol>
65<li>On your Android device, <a href="http://haysmark.dojotoolkit.org/android-server.apk">download the patched WebDriver apk</a> and start it. You will get a black screen that says WebDriver at the top.</li>
66<li>Enter the IP of your Android device: <input type=text id="baseIP" name="baseIP" value="myandroidIP" /></li>
67<li>Open the Network tab in the browser's debugger</li>
68<li>Press <button type="button" id="button" data-dojo-type="dijit/form/Button" data-dojo-props='type:"button",label:"Submit"'>
69        <script type="dojo/method" data-dojo-event="onClick" data-dojo-args="evt">
70                onSubmit1();
71        </script>
72</button></li>
73<li>Enter the number you see in the Network tab for the failed redirect (should look something like 1342108893269 for instance): <input type=text id="sessionID" name="sessionID" value="1342108893269" /></li>
74<li>Enter the DOH mobileRunner.html URL you want to test (note the loaded plugin at the end): <input type=text id="testURL" name="testURL" value="http://mywebserver/util/doh/mobileRunner.html?test=dojox/mobile/tests/robot/module&dohPlugins=doh/plugins/remoteRobot" /></li>
75<li>Press <button type="button" id="button2" data-dojo-type="dijit/form/Button" data-dojo-props='type:"button",label:"Submit"'>
76        <script type="dojo/method" data-dojo-event="onClick" data-dojo-args="evt">
77                onSubmit2();
78        </script>
79</button></li>
80<li>The test should momentarily start (after ~10s) on the device (if it doesn't load after a minute, repeat the procedure; some times an unbuilt Dojo will time out while the browser is caching everything for the first time.)</li>
81<hr />
82<h1 id="status" />
83<div id="message" />
84</body>
85</html>
Note: See TracBrowser for help on using the repository browser.