Skip to content

Commit

Permalink
add test for existing xml source behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
jlipps committed Mar 28, 2014
1 parent f8f3038 commit 78f3a43
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/functional/android/apidemos/source-specs.js
@@ -1,6 +1,8 @@
"use strict";

var setup = require("../../common/setup-base")
, xpath = require("xpath")
, XMLDom = require("xmldom").DOMParser
, desired = require("./desired");

describe("apidemos - source -", function () {
Expand All @@ -16,11 +18,21 @@ describe("apidemos - source -", function () {
source.should.include('@class');
var obj = JSON.parse(source);
obj.should.exist;
// probably no need for so precise tests
// probably no need for so precise tests
//obj.hierarchy.node['@class'].should.equal("android.widget.FrameLayout");
//obj.hierarchy.node.node.node[0].node['@class'].should.equal("android.widget.FrameLayout");
}).nodeify(done);
});
it('should return the page source as xml', function (done) {
driver
.elementByNameOrNull('Accessibility') // waiting for page to load
.execute("mobile: source", [{type: 'xml'}]).then(function (source) {
source.should.exist;
var dom = new XMLDom().parseFromString(source);
var nodes = xpath.select('//node[@content-desc="App"]', dom);
nodes.length.should.equal(1);
}).nodeify(done);
});
it('should return the page source without crashing other commands', function (done) {
driver
.execute("mobile: find", [[[[3, "Animation"]]]])
Expand All @@ -30,7 +42,7 @@ describe("apidemos - source -", function () {
source.should.include('@class');
var obj = JSON.parse(source);
obj.should.exist;
// probably no need for so precise tests
// probably no need for so precise tests
//obj.hierarchy.node['@class'].should.equal("android.widget.FrameLayout");
//obj.hierarchy.node.node.node[0].node['@class'].should.equal("android.widget.FrameLayout");
}).execute("mobile: find", [[[[3, "Animation"]]]])
Expand Down

0 comments on commit 78f3a43

Please sign in to comment.