Skip to content

Instantly share code, notes, and snippets.

@DominikDary
Created February 10, 2014 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DominikDary/8915320 to your computer and use it in GitHub Desktop.
Save DominikDary/8915320 to your computer and use it in GitHub Desktop.
Sample of selendroid's source format. <code>driver.getPageSource()</code> returns a json reply that contains e.g. the source code of the the webview and as well a generated xml source of the activity. The generated xml will be used to apply xpath expressions. A screenshot of the corresponding Inspector can be found here: https://dl.dropboxuserco…
{
"id": "[DecorView]",
"data": "[DecorView]",
"children": [{
"id": "[LinearLayout]",
"data": "[LinearLayout]",
"children": [{
"id": "[ViewStub]-action_mode_bar...",
"data": "[ViewStub]-action_mode_bar...",
"attr": {
"id": "c4ffce53-c82b-5038-02ed-81bebd1ed432"
},
"metadata": {
"id": "action_mode_bar_stub",
"l10n": {
"matches": 0
},
"source": "",
"name": "null",
"value": "",
"shown": false,
"rect": {
"w": 0,
"h": 0,
"y": 0,
"x": 0
},
"type": "ViewStub",
"reference": "c4ffce53-c82b-5038-02ed-81bebd1ed432"
}
}, {
"id": "[FrameLayout]",
"data": "[FrameLayout]",
"children": [{
"id": "[TextView]-title",
"data": "[TextView]-title",
"attr": {
"id": "a24a7377-c877-198d-d09d-04c5a3f71df2"
},
"metadata": {
"id": "title",
"l10n": {
"matches": 0
},
"source": "",
"name": "null",
"value": "selendroid-test-app",
"shown": true,
"rect": {
"w": 704,
"h": 46,
"y": 51,
"x": 8
},
"type": "TextView",
"reference": "a24a7377-c877-198d-d09d-04c5a3f71df2"
}
}],
"attr": {
"id": "08ef3a13-c4ae-385b-7013-5f4b77453915"
},
"metadata": {
"id": "",
"l10n": {
"matches": 0
},
"source": "",
"name": "null",
"value": "",
"shown": true,
"rect": {
"w": 720,
"h": 50,
"y": 50,
"x": 0
},
"type": "FrameLayout",
"reference": "08ef3a13-c4ae-385b-7013-5f4b77453915"
}
}, {
"id": "[FrameLayout]-content",
"data": "[FrameLayout]-content",
"children": [{
"id": "[TableLayout]-webviewTable",
"data": "[TableLayout]-webviewTable",
"children": [{
"id": "[TableRow]-tableHeader",
"data": "[TableRow]-tableHeader",
"children": [{
"id": "[TextView]",
"data": "[TextView]",
"attr": {
"id": "5b4fdbb5-25bf-23dc-e0cc-e4a3da09c934"
},
"metadata": {
"id": "",
"l10n": {
"matches": 0
},
"source": "",
"name": "null",
"value": "Web View Interaction",
"shown": true,
"rect": {
"w": 405,
"h": 38,
"y": 100,
"x": 157
},
"type": "TextView",
"reference": "5b4fdbb5-25bf-23dc-e0cc-e4a3da09c934"
}
}],
"attr": {
"id": "cc834cb1-1d5c-3886-8e52-b187ae8a5089"
},
"metadata": {
"id": "tableHeader",
"l10n": {
"matches": 0
},
"source": "",
"name": "null",
"value": "",
"shown": true,
"rect": {
"w": 720,
"h": 38,
"y": 100,
"x": 0
},
"type": "TableRow",
"reference": "cc834cb1-1d5c-3886-8e52-b187ae8a5089"
}
}, {
"id": "[TableRow]-tableRowButtons",
"data": "[TableRow]-tableRowButtons",
"children": [{
"id": "[SelendroidSpinner]-spinner_webdriv...",
"data": "[SelendroidSpinner]-spinner_webdriv...",
"children": [{
"id": "[TextView]-text1",
"data": "[TextView]-text1",
"attr": {
"id": "3a18d2f3-b92c-ec16-30a6-34d834ccf3b2"
},
"metadata": {
"id": "text1",
"l10n": {
"matches": 0
},
"source": "",
"name": "null",
"value": "'Say Hello'-Demo",
"shown": true,
"rect": {
"w": 281,
"h": 43,
"y": 160,
"x": 21
},
"type": "TextView",
"reference": "3a18d2f3-b92c-ec16-30a6-34d834ccf3b2"
}
}],
"attr": {
"id": "9eca16c2-9920-8cf7-bf79-e4da289005c2"
},
"metadata": {
"id": "spinner_webdriver_test_data",
"l10n": {
"matches": 0
},
"source": "",
"name": "null",
"value": "",
"shown": true,
"rect": {
"w": 405,
"h": 97,
"y": 138,
"x": 0
},
"type": "SelendroidSpinner",
"reference": "9eca16c2-9920-8cf7-bf79-e4da289005c2"
}
}, {
"id": "[Button]-goBack",
"data": "[Button]-goBack",
"attr": {
"id": "8b138987-0845-2b59-cc0e-271249b3965c"
},
"metadata": {
"id": "goBack",
"l10n": {
"matches": 0
},
"source": "",
"name": "null",
"value": "Go to home screen",
"shown": true,
"rect": {
"w": 315,
"h": 96,
"y": 140,
"x": 405
},
"type": "Button",
"reference": "8b138987-0845-2b59-cc0e-271249b3965c"
}
}],
"attr": {
"id": "5dc6d70a-d73a-6939-39dc-b1698f714abf"
},
"metadata": {
"id": "tableRowButtons",
"l10n": {
"matches": 0
},
"source": "",
"name": "null",
"value": "",
"shown": true,
"rect": {
"w": 720,
"h": 97,
"y": 138,
"x": 0
},
"type": "TableRow",
"reference": "5dc6d70a-d73a-6939-39dc-b1698f714abf"
}
}, {
"id": "[TableRow]-tableRowWebview",
"data": "[TableRow]-tableRowWebview",
"children": [{
"id": "[WebView]-mainWebView",
"data": "[WebView]-mainWebView",
"attr": {
"id": "169c187e-1407-68c4-61d1-57e0f6c9cdb7"
},
"metadata": {
"id": "mainWebView",
"l10n": {
"matches": 0
},
"source": "<html><head><title>Say Hello Demo<\/title><\/head><body>Hello, can you please tell me your name?<form name=\"myform\" action=\"http:\/\/localhost:4450\/sayhello\" method=\"get\"><div align=\"center\"><br><br><input type=\"text\" id=\"name_input\" name=\"name\" size=\"25\" value=\"Enter your name here!\"><br><p>Prefered Car:<br><select name=\"car\"><option value=\"volvo\">Volvo<\/option><option value=\"mercedes\">Mercedes<\/option><option value=\"audi\">Audi<\/option><\/select><\/p><br><input type=\"submit\" value=\"Send me your name!\"><br><\/div><\/form><\/body><\/html>",
"name": "null",
"value": "",
"shown": true,
"rect": {
"w": 720,
"h": 500,
"y": 235,
"x": 0
},
"type": "WebView",
"reference": "169c187e-1407-68c4-61d1-57e0f6c9cdb7"
}
}],
"attr": {
"id": "5e1b271e-6040-6998-2035-3a1394f1c6a6"
},
"metadata": {
"id": "tableRowWebview",
"l10n": {
"matches": 0
},
"source": "",
"name": "null",
"value": "",
"shown": true,
"rect": {
"w": 720,
"h": 500,
"y": 235,
"x": 0
},
"type": "TableRow",
"reference": "5e1b271e-6040-6998-2035-3a1394f1c6a6"
}
}],
"attr": {
"id": "5fc65183-7f2b-e85e-0126-bd836398694e"
},
"metadata": {
"id": "webviewTable",
"l10n": {
"matches": 0
},
"source": "",
"name": "null",
"value": "",
"shown": true,
"rect": {
"w": 720,
"h": 1084,
"y": 100,
"x": 0
},
"type": "TableLayout",
"reference": "5fc65183-7f2b-e85e-0126-bd836398694e"
}
}],
"attr": {
"id": "b4d2c4cf-25de-709d-444e-b504460bab86"
},
"metadata": {
"id": "content",
"l10n": {
"matches": 0
},
"source": "",
"name": "null",
"value": "",
"shown": true,
"rect": {
"w": 720,
"h": 1084,
"y": 100,
"x": 0
},
"type": "FrameLayout",
"reference": "b4d2c4cf-25de-709d-444e-b504460bab86"
}
}],
"attr": {
"id": "a208efd8-ea74-b904-2ef9-f78cfa2f6e5f"
},
"metadata": {
"id": "",
"l10n": {
"matches": 0
},
"source": "",
"name": "null",
"value": "",
"shown": true,
"rect": {
"w": 720,
"h": 1184,
"y": 0,
"x": 0
},
"type": "LinearLayout",
"reference": "a208efd8-ea74-b904-2ef9-f78cfa2f6e5f"
}
}],
"attr": {
"id": "271c79e2-897f-33ee-378e-8945a3eefdab"
},
"metadata": {
"id": "",
"l10n": {
"matches": 0
},
"source": "",
"name": "null",
"value": "",
"shown": true,
"xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><views><DecorView name=\"null\" label=\"\" value=\"\" ref=\"271c79e2-897f-33ee-378e-8945a3eefdab\" id=\"\" shown=\"true\"><LinearLayout name=\"null\" label=\"\" value=\"\" ref=\"a208efd8-ea74-b904-2ef9-f78cfa2f6e5f\" id=\"\" shown=\"true\"><ViewStub name=\"null\" label=\"\" value=\"\" ref=\"c4ffce53-c82b-5038-02ed-81bebd1ed432\" id=\"action_mode_bar_stub\" shown=\"false\"\/><FrameLayout name=\"null\" label=\"\" value=\"\" ref=\"08ef3a13-c4ae-385b-7013-5f4b77453915\" id=\"\" shown=\"true\"><TextView name=\"null\" label=\"\" value=\"selendroid-test-app\" ref=\"a24a7377-c877-198d-d09d-04c5a3f71df2\" id=\"title\" shown=\"true\"\/><\/FrameLayout><FrameLayout name=\"null\" label=\"\" value=\"\" ref=\"b4d2c4cf-25de-709d-444e-b504460bab86\" id=\"content\" shown=\"true\"><TableLayout name=\"null\" label=\"\" value=\"\" ref=\"5fc65183-7f2b-e85e-0126-bd836398694e\" id=\"webviewTable\" shown=\"true\"><TableRow name=\"null\" label=\"\" value=\"\" ref=\"cc834cb1-1d5c-3886-8e52-b187ae8a5089\" id=\"tableHeader\" shown=\"true\"><TextView name=\"null\" label=\"\" value=\"Web View Interaction\" ref=\"5b4fdbb5-25bf-23dc-e0cc-e4a3da09c934\" id=\"\" shown=\"true\"\/><\/TableRow><TableRow name=\"null\" label=\"\" value=\"\" ref=\"5dc6d70a-d73a-6939-39dc-b1698f714abf\" id=\"tableRowButtons\" shown=\"true\"><SelendroidSpinner name=\"null\" label=\"\" value=\"\" ref=\"9eca16c2-9920-8cf7-bf79-e4da289005c2\" id=\"spinner_webdriver_test_data\" shown=\"true\"><TextView name=\"null\" label=\"\" value=\"'Say Hello'-Demo\" ref=\"3a18d2f3-b92c-ec16-30a6-34d834ccf3b2\" id=\"text1\" shown=\"true\"\/><\/SelendroidSpinner><Button name=\"null\" label=\"\" value=\"Go to home screen\" ref=\"8b138987-0845-2b59-cc0e-271249b3965c\" id=\"goBack\" shown=\"true\"\/><\/TableRow><TableRow name=\"null\" label=\"\" value=\"\" ref=\"5e1b271e-6040-6998-2035-3a1394f1c6a6\" id=\"tableRowWebview\" shown=\"true\"><WebView name=\"null\" label=\"\" value=\"\" ref=\"169c187e-1407-68c4-61d1-57e0f6c9cdb7\" id=\"mainWebView\" shown=\"true\"\/><\/TableRow><\/TableLayout><\/FrameLayout><\/LinearLayout><\/DecorView><\/views>",
"rect": {
"w": 720,
"h": 1184,
"y": 0,
"x": 0
},
"type": "DecorView",
"reference": "271c79e2-897f-33ee-378e-8945a3eefdab"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<views>
<DecorView name="" label="" value="" ref="271c79e2-897f-33ee-378e-8945a3eefdab" id="" shown="true">
<LinearLayout name="" label="" value="" ref="a208efd8-ea74-b904-2ef9-f78cfa2f6e5f" id="" shown="true">
<ViewStub name="" label="" value="" ref="c4ffce53-c82b-5038-02ed-81bebd1ed432" id="action_mode_bar_stub" shown="false"/>
<FrameLayout name="" label="" value="" ref="08ef3a13-c4ae-385b-7013-5f4b77453915" id="" shown="true">
<TextView name="" label="" value="selendroid-test-app" ref="a24a7377-c877-198d-d09d-04c5a3f71df2" id="title" shown="true"/>
</FrameLayout>
<FrameLayout name="" label="" value="" ref="b4d2c4cf-25de-709d-444e-b504460bab86" id="content" shown="true">
<TableLayout name="" label="" value="" ref="5fc65183-7f2b-e85e-0126-bd836398694e" id="webviewTable" shown="true">
<TableRow name="" label="" value="" ref="cc834cb1-1d5c-3886-8e52-b187ae8a5089" id="tableHeader" shown="true">
<TextView name="" label="" value="Web View Interaction" ref="5b4fdbb5-25bf-23dc-e0cc-e4a3da09c934" id="" shown="true"/>
</TableRow>
<TableRow name="" label="" value="" ref="5dc6d70a-d73a-6939-39dc-b1698f714abf" id="tableRowButtons" shown="true">
<SelendroidSpinner name="" label="" value="" ref="9eca16c2-9920-8cf7-bf79-e4da289005c2" id="spinner_webdriver_test_data" shown="true">
<TextView name="" label="" value="'Say Hello'-Demo" ref="3a18d2f3-b92c-ec16-30a6-34d834ccf3b2" id="text1" shown="true"/>
</SelendroidSpinner>
<Button name="" label="" value="Go to home screen" ref="8b138987-0845-2b59-cc0e-271249b3965c" id="goBack" shown="true"/>
</TableRow>
<TableRow name="" label="" value="" ref="5e1b271e-6040-6998-2035-3a1394f1c6a6" id="tableRowWebview" shown="true">
<WebView name="" label="" value="" ref="169c187e-1407-68c4-61d1-57e0f6c9cdb7" id="mainWebView" shown="true"/>
</TableRow>
</TableLayout>
</FrameLayout>
</LinearLayout>
</DecorView>
</views>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment