@appium/universal-xml-plugin 1.0.0-beta.4 → 1.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +1 -1
- package/build/lib/attr-map.d.ts +58 -0
- package/build/lib/attr-map.d.ts.map +1 -0
- package/build/lib/attr-map.js +47 -32
- package/build/lib/index.d.ts +5 -0
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/index.js +49 -0
- package/build/lib/logger.d.ts +3 -0
- package/build/lib/logger.d.ts.map +1 -0
- package/build/lib/logger.js +15 -5
- package/build/lib/node-map.d.ts +200 -0
- package/build/lib/node-map.d.ts.map +1 -0
- package/build/lib/node-map.js +146 -267
- package/build/lib/plugin.d.ts +9 -0
- package/build/lib/plugin.d.ts.map +1 -0
- package/build/lib/plugin.js +90 -93
- package/build/lib/source.d.ts +24 -0
- package/build/lib/source.d.ts.map +1 -0
- package/build/lib/source.js +202 -148
- package/build/lib/transformers.d.ts +8 -0
- package/build/lib/transformers.d.ts.map +1 -0
- package/build/lib/transformers.js +35 -26
- package/build/lib/xpath.d.ts +4 -0
- package/build/lib/xpath.d.ts.map +1 -0
- package/build/lib/xpath.js +46 -40
- package/build/tsconfig.tsbuildinfo +1 -0
- package/index.js +3 -17
- package/lib/index.js +19 -0
- package/lib/logger.js +1 -1
- package/lib/plugin.js +2 -10
- package/package.json +30 -21
- package/build/index.js +0 -25
- package/build/test/fixtures/android-transformed-path.xml +0 -39
- package/build/test/fixtures/android-transformed.xml +0 -39
- package/build/test/fixtures/android.xml +0 -39
- package/build/test/fixtures/index.js +0 -25
- package/build/test/fixtures/ios-edge.xml +0 -16
- package/build/test/fixtures/ios-transformed-edge.xml +0 -16
- package/build/test/fixtures/ios-transformed-path.xml +0 -54
- package/build/test/fixtures/ios-transformed.xml +0 -54
- package/build/test/fixtures/ios.xml +0 -51
- package/build/test/unit/plugin-specs.js +0 -76
- package/build/test/unit/source-specs.js +0 -82
- package/build/test/unit/xpath-specs.js +0 -46
- package/test/fixtures/android-transformed-path.xml +0 -39
- package/test/fixtures/android-transformed.xml +0 -39
- package/test/fixtures/android.xml +0 -39
- package/test/fixtures/index.js +0 -14
- package/test/fixtures/ios-edge.xml +0 -16
- package/test/fixtures/ios-transformed-edge.xml +0 -16
- package/test/fixtures/ios-transformed-path.xml +0 -54
- package/test/fixtures/ios-transformed.xml +0 -54
- package/test/fixtures/ios.xml +0 -51
- package/test/unit/plugin-specs.js +0 -57
- package/test/unit/source-specs.js +0 -79
- package/test/unit/xpath-specs.js +0 -43
- package/tsconfig.json +0 -15
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<UI>
|
|
3
|
-
<App visible="true" x="0" y="0" width="414" height="896" axId="TheApp" text="TheApp">
|
|
4
|
-
<SomeRandoElement oddAttribute="odd"></SomeRandoElement>
|
|
5
|
-
<SomeRandoElement oddAttribute="odd"></SomeRandoElement>
|
|
6
|
-
<Element visible="true" x="50" y="185" width="314" height="51" axId="username" text="username">
|
|
7
|
-
<TextInput value="alice" visible="true" x="50" y="185" width="314" height="51" axId="username" text="username"></TextInput>
|
|
8
|
-
<Button visible="true" x="50" y="185" width="314" height="51" axId="fakeTab" text=""></Button>
|
|
9
|
-
<Button visible="true" x="50" y="185" width="314" height="51" axId="fakeTab" text=""></Button>
|
|
10
|
-
<Button visible="true" x="50" y="185" width="314" height="51" axId="fakeKey" text="">
|
|
11
|
-
<Element visible="true" x="1" y="2" width="3" height="4" axId="fakeOther" text=""></Element>
|
|
12
|
-
</Button>
|
|
13
|
-
<Button visible="true" x="50" y="185" width="314" height="51" axId="fakeKey" text=""></Button>
|
|
14
|
-
</Element>
|
|
15
|
-
</App>
|
|
16
|
-
</UI>
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<UI indexPath="/0">
|
|
3
|
-
<App visible="true" x="0" y="0" width="414" height="896" indexPath="/0/0" axId="TheApp" text="TheApp">
|
|
4
|
-
<Window visible="true" x="0" y="0" width="414" height="896" indexPath="/0/0/0">
|
|
5
|
-
<Element visible="true" x="0" y="0" width="414" height="896" indexPath="/0/0/0/0">
|
|
6
|
-
<Nav visible="true" x="0" y="48" width="414" height="44" indexPath="/0/0/0/0/0" axId="RCCView">
|
|
7
|
-
<Button visible="true" x="0" y="48" width="96" height="44" indexPath="/0/0/0/0/0/0" axId="The App" text="The App"></Button>
|
|
8
|
-
</Nav>
|
|
9
|
-
<Element visible="true" x="0" y="0" width="414" height="896" indexPath="/0/0/0/0/1">
|
|
10
|
-
<Element visible="true" x="0" y="0" width="414" height="896" indexPath="/0/0/0/0/1/0">
|
|
11
|
-
<Element visible="true" x="0" y="92" width="414" height="804" indexPath="/0/0/0/0/1/0/0">
|
|
12
|
-
<Element visible="true" x="0" y="92" width="414" height="804" indexPath="/0/0/0/0/1/0/0/0" axId="Login username password loginBtn" text="Login username password loginBtn">
|
|
13
|
-
<Element visible="true" x="0" y="92" width="414" height="804" indexPath="/0/0/0/0/1/0/0/0/0" axId="Login username password loginBtn" text="Login username password loginBtn">
|
|
14
|
-
<Element visible="true" x="0" y="92" width="414" height="804" indexPath="/0/0/0/0/1/0/0/0/0/0" axId="Login username password loginBtn" text="Login username password loginBtn">
|
|
15
|
-
<Element visible="true" x="0" y="92" width="414" height="273" indexPath="/0/0/0/0/1/0/0/0/0/0/0" axId="Login username password loginBtn" text="Login username password loginBtn">
|
|
16
|
-
<Text value="Login" visible="true" x="157" y="132" width="101" height="51" indexPath="/0/0/0/0/1/0/0/0/0/0/0/0" axId="Login" text="Login"></Text>
|
|
17
|
-
<Element visible="true" x="50" y="183" width="314" height="40" indexPath="/0/0/0/0/1/0/0/0/0/0/0/1" axId="username" text="username">
|
|
18
|
-
<Element visible="true" x="50" y="183" width="314" height="40" indexPath="/0/0/0/0/1/0/0/0/0/0/0/1/0" axId="username" text="username">
|
|
19
|
-
<Element visible="true" x="50" y="185" width="314" height="51" indexPath="/0/0/0/0/1/0/0/0/0/0/0/1/0/0" axId="username" text="username">
|
|
20
|
-
<TextInput value="alice" visible="true" x="50" y="185" width="314" height="51" indexPath="/0/0/0/0/1/0/0/0/0/0/0/1/0/0/0" axId="username" text="username"></TextInput>
|
|
21
|
-
<Button visible="true" x="50" y="185" width="314" height="51" indexPath="/0/0/0/0/1/0/0/0/0/0/0/1/0/0/1" axId="fakeTab" text=""></Button>
|
|
22
|
-
<Button visible="true" x="50" y="185" width="314" height="51" indexPath="/0/0/0/0/1/0/0/0/0/0/0/1/0/0/2" axId="fakeKey" text=""></Button>
|
|
23
|
-
</Element>
|
|
24
|
-
</Element>
|
|
25
|
-
</Element>
|
|
26
|
-
<Element visible="true" x="50" y="223" width="314" height="40" indexPath="/0/0/0/0/1/0/0/0/0/0/0/2" axId="password" text="password">
|
|
27
|
-
<Element visible="true" x="50" y="223" width="314" height="40" indexPath="/0/0/0/0/1/0/0/0/0/0/0/2/0" axId="password" text="password">
|
|
28
|
-
<Element visible="true" x="50" y="225" width="314" height="51" indexPath="/0/0/0/0/1/0/0/0/0/0/0/2/0/0" axId="password" text="password">
|
|
29
|
-
<TextInput value="•••••••••" visible="true" x="50" y="225" width="314" height="51" indexPath="/0/0/0/0/1/0/0/0/0/0/0/2/0/0/0" axId="password" text="password"></TextInput>
|
|
30
|
-
</Element>
|
|
31
|
-
</Element>
|
|
32
|
-
</Element>
|
|
33
|
-
<Element visible="true" x="177" y="263" width="60" height="102" indexPath="/0/0/0/0/1/0/0/0/0/0/0/3" axId="loginBtn" text="loginBtn">
|
|
34
|
-
<Element visible="true" x="177" y="327" width="60" height="38" indexPath="/0/0/0/0/1/0/0/0/0/0/0/3/0" axId="loginBtn" text="loginBtn"></Element>
|
|
35
|
-
</Element>
|
|
36
|
-
</Element>
|
|
37
|
-
</Element>
|
|
38
|
-
</Element>
|
|
39
|
-
</Element>
|
|
40
|
-
</Element>
|
|
41
|
-
</Element>
|
|
42
|
-
</Element>
|
|
43
|
-
</Element>
|
|
44
|
-
</Window>
|
|
45
|
-
<Window visible="false" x="0" y="0" width="414" height="896" indexPath="/0/0/1">
|
|
46
|
-
<Element visible="false" x="0" y="0" width="414" height="896" indexPath="/0/0/1/0">
|
|
47
|
-
<Element visible="false" x="0" y="0" width="414" height="896" indexPath="/0/0/1/0/0"></Element>
|
|
48
|
-
<Element visible="false" x="0" y="896" width="414" height="71" indexPath="/0/0/1/0/1">
|
|
49
|
-
<Element visible="false" x="0" y="896" width="414" height="71" indexPath="/0/0/1/0/1/0"></Element>
|
|
50
|
-
</Element>
|
|
51
|
-
</Element>
|
|
52
|
-
</Window>
|
|
53
|
-
</App>
|
|
54
|
-
</UI>
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<UI>
|
|
3
|
-
<App visible="true" x="0" y="0" width="414" height="896" axId="TheApp" text="TheApp">
|
|
4
|
-
<Window visible="true" x="0" y="0" width="414" height="896">
|
|
5
|
-
<Element visible="true" x="0" y="0" width="414" height="896">
|
|
6
|
-
<Nav visible="true" x="0" y="48" width="414" height="44" axId="RCCView">
|
|
7
|
-
<Button visible="true" x="0" y="48" width="96" height="44" axId="The App" text="The App"></Button>
|
|
8
|
-
</Nav>
|
|
9
|
-
<Element visible="true" x="0" y="0" width="414" height="896">
|
|
10
|
-
<Element visible="true" x="0" y="0" width="414" height="896">
|
|
11
|
-
<Element visible="true" x="0" y="92" width="414" height="804">
|
|
12
|
-
<Element visible="true" x="0" y="92" width="414" height="804" axId="Login username password loginBtn" text="Login username password loginBtn">
|
|
13
|
-
<Element visible="true" x="0" y="92" width="414" height="804" axId="Login username password loginBtn" text="Login username password loginBtn">
|
|
14
|
-
<Element visible="true" x="0" y="92" width="414" height="804" axId="Login username password loginBtn" text="Login username password loginBtn">
|
|
15
|
-
<Element visible="true" x="0" y="92" width="414" height="273" axId="Login username password loginBtn" text="Login username password loginBtn">
|
|
16
|
-
<Text value="Login" visible="true" x="157" y="132" width="101" height="51" axId="Login" text="Login"></Text>
|
|
17
|
-
<Element visible="true" x="50" y="183" width="314" height="40" axId="username" text="username">
|
|
18
|
-
<Element visible="true" x="50" y="183" width="314" height="40" axId="username" text="username">
|
|
19
|
-
<Element visible="true" x="50" y="185" width="314" height="51" axId="username" text="username">
|
|
20
|
-
<TextInput value="alice" visible="true" x="50" y="185" width="314" height="51" axId="username" text="username"></TextInput>
|
|
21
|
-
<Button visible="true" x="50" y="185" width="314" height="51" axId="fakeTab" text=""></Button>
|
|
22
|
-
<Button visible="true" x="50" y="185" width="314" height="51" axId="fakeKey" text=""></Button>
|
|
23
|
-
</Element>
|
|
24
|
-
</Element>
|
|
25
|
-
</Element>
|
|
26
|
-
<Element visible="true" x="50" y="223" width="314" height="40" axId="password" text="password">
|
|
27
|
-
<Element visible="true" x="50" y="223" width="314" height="40" axId="password" text="password">
|
|
28
|
-
<Element visible="true" x="50" y="225" width="314" height="51" axId="password" text="password">
|
|
29
|
-
<TextInput value="•••••••••" visible="true" x="50" y="225" width="314" height="51" axId="password" text="password"></TextInput>
|
|
30
|
-
</Element>
|
|
31
|
-
</Element>
|
|
32
|
-
</Element>
|
|
33
|
-
<Element visible="true" x="177" y="263" width="60" height="102" axId="loginBtn" text="loginBtn">
|
|
34
|
-
<Element visible="true" x="177" y="327" width="60" height="38" axId="loginBtn" text="loginBtn"></Element>
|
|
35
|
-
</Element>
|
|
36
|
-
</Element>
|
|
37
|
-
</Element>
|
|
38
|
-
</Element>
|
|
39
|
-
</Element>
|
|
40
|
-
</Element>
|
|
41
|
-
</Element>
|
|
42
|
-
</Element>
|
|
43
|
-
</Element>
|
|
44
|
-
</Window>
|
|
45
|
-
<Window visible="false" x="0" y="0" width="414" height="896">
|
|
46
|
-
<Element visible="false" x="0" y="0" width="414" height="896">
|
|
47
|
-
<Element visible="false" x="0" y="0" width="414" height="896"></Element>
|
|
48
|
-
<Element visible="false" x="0" y="896" width="414" height="71">
|
|
49
|
-
<Element visible="false" x="0" y="896" width="414" height="71"></Element>
|
|
50
|
-
</Element>
|
|
51
|
-
</Element>
|
|
52
|
-
</Window>
|
|
53
|
-
</App>
|
|
54
|
-
</UI>
|
package/test/fixtures/ios.xml
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?><AppiumAUT><XCUIElementTypeApplication type="XCUIElementTypeApplication" name="TheApp" label="TheApp" enabled="true" visible="true" x="0" y="0" width="414" height="896" index="0">
|
|
2
|
-
<XCUIElementTypeWindow type="XCUIElementTypeWindow" enabled="true" visible="true" x="0" y="0" width="414" height="896" index="0">
|
|
3
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="0" y="0" width="414" height="896" index="0">
|
|
4
|
-
<XCUIElementTypeNavigationBar type="XCUIElementTypeNavigationBar" name="RCCView" enabled="true" visible="true" x="0" y="48" width="414" height="44" index="0">
|
|
5
|
-
<XCUIElementTypeButton type="XCUIElementTypeButton" name="The App" label="The App" enabled="true" visible="true" x="0" y="48" width="96" height="44" index="0"/>
|
|
6
|
-
</XCUIElementTypeNavigationBar>
|
|
7
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="0" y="0" width="414" height="896" index="1">
|
|
8
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="0" y="0" width="414" height="896" index="0">
|
|
9
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="0" y="92" width="414" height="804" index="0">
|
|
10
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" name="Login username password loginBtn" label="Login username password loginBtn" enabled="true" visible="true" x="0" y="92" width="414" height="804" index="0">
|
|
11
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" name="Login username password loginBtn" label="Login username password loginBtn" enabled="true" visible="true" x="0" y="92" width="414" height="804" index="0">
|
|
12
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" name="Login username password loginBtn" label="Login username password loginBtn" enabled="true" visible="true" x="0" y="92" width="414" height="804" index="0">
|
|
13
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" name="Login username password loginBtn" label="Login username password loginBtn" enabled="true" visible="true" x="0" y="92" width="414" height="273" index="0">
|
|
14
|
-
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Login" name="Login" label="Login" enabled="true" visible="true" x="157" y="132" width="101" height="51" index="0"/>
|
|
15
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" name="username" label="username" enabled="true" visible="true" x="50" y="183" width="314" height="40" index="1">
|
|
16
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" name="username" label="username" enabled="true" visible="true" x="50" y="183" width="314" height="40" index="0">
|
|
17
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" name="username" label="username" enabled="true" visible="true" x="50" y="185" width="314" height="51" index="0">
|
|
18
|
-
<XCUIElementTypeTextField type="XCUIElementTypeTextField" value="alice" name="username" label="username" enabled="true" visible="true" x="50" y="185" width="314" height="51" index="0"/>
|
|
19
|
-
<XCUIElementTypeTab type="XCUIElementTypeTab" name="fakeTab" label="" enabled="" visible="true" x="50" y="185" width="314" height="51" index="1"/>
|
|
20
|
-
<XCUIElementTypeKey type="XCUIElementTypeKey" name="fakeKey" label="" enabled="" visible="true" x="50" y="185" width="314" height="51" index="2"/>
|
|
21
|
-
</XCUIElementTypeOther>
|
|
22
|
-
</XCUIElementTypeOther>
|
|
23
|
-
</XCUIElementTypeOther>
|
|
24
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" name="password" label="password" enabled="true" visible="true" x="50" y="223" width="314" height="40" index="2">
|
|
25
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" name="password" label="password" enabled="true" visible="true" x="50" y="223" width="314" height="40" index="0">
|
|
26
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" name="password" label="password" enabled="true" visible="true" x="50" y="225" width="314" height="51" index="0">
|
|
27
|
-
<XCUIElementTypeSecureTextField type="XCUIElementTypeSecureTextField" value="•••••••••" name="password" label="password" enabled="true" visible="true" x="50" y="225" width="314" height="51" index="0"/>
|
|
28
|
-
</XCUIElementTypeOther>
|
|
29
|
-
</XCUIElementTypeOther>
|
|
30
|
-
</XCUIElementTypeOther>
|
|
31
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" name="loginBtn" label="loginBtn" enabled="true" visible="true" x="177" y="263" width="60" height="102" index="3">
|
|
32
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" name="loginBtn" label="loginBtn" enabled="true" visible="true" x="177" y="327" width="60" height="38" index="0"/>
|
|
33
|
-
</XCUIElementTypeOther>
|
|
34
|
-
</XCUIElementTypeOther>
|
|
35
|
-
</XCUIElementTypeOther>
|
|
36
|
-
</XCUIElementTypeOther>
|
|
37
|
-
</XCUIElementTypeOther>
|
|
38
|
-
</XCUIElementTypeOther>
|
|
39
|
-
</XCUIElementTypeOther>
|
|
40
|
-
</XCUIElementTypeOther>
|
|
41
|
-
</XCUIElementTypeOther>
|
|
42
|
-
</XCUIElementTypeWindow>
|
|
43
|
-
<XCUIElementTypeWindow type="XCUIElementTypeWindow" enabled="true" visible="false" x="0" y="0" width="414" height="896" index="1">
|
|
44
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" x="0" y="0" width="414" height="896" index="0">
|
|
45
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" x="0" y="0" width="414" height="896" index="0"/>
|
|
46
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" x="0" y="896" width="414" height="71" index="1">
|
|
47
|
-
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" x="0" y="896" width="414" height="71" index="0"/>
|
|
48
|
-
</XCUIElementTypeOther>
|
|
49
|
-
</XCUIElementTypeOther>
|
|
50
|
-
</XCUIElementTypeWindow>
|
|
51
|
-
</XCUIElementTypeApplication></AppiumAUT>
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import chai from 'chai';
|
|
2
|
-
import chaiAsPromised from 'chai-as-promised';
|
|
3
|
-
import UniversalXMLPlugin from '../../index';
|
|
4
|
-
import BaseDriver from 'appium-base-driver';
|
|
5
|
-
import { XML_IOS, XML_ANDROID, XML_IOS_TRANSFORMED, XML_ANDROID_TRANSFORMED } from '../fixtures';
|
|
6
|
-
import { runQuery, getNodeAttrVal } from '../../lib/xpath';
|
|
7
|
-
|
|
8
|
-
chai.use(chaiAsPromised);
|
|
9
|
-
chai.should();
|
|
10
|
-
|
|
11
|
-
describe('UniversalXMLPlugin', function () {
|
|
12
|
-
const next = () => true;
|
|
13
|
-
const p = new UniversalXMLPlugin();
|
|
14
|
-
describe('getPageSource', function () {
|
|
15
|
-
const driver = new BaseDriver();
|
|
16
|
-
it('should transform page source for ios', async function () {
|
|
17
|
-
driver.getPageSource = () => XML_IOS;
|
|
18
|
-
driver.caps = {platformName: 'iOS'};
|
|
19
|
-
await p.getPageSource(next, driver).should.eventually.eql(XML_IOS_TRANSFORMED);
|
|
20
|
-
});
|
|
21
|
-
it('should transform page source for android', async function () {
|
|
22
|
-
driver.getPageSource = () => XML_ANDROID;
|
|
23
|
-
driver.caps = {platformName: 'Android'};
|
|
24
|
-
driver.opts = {appPackage: 'io.cloudgrey.the_app'};
|
|
25
|
-
await p.getPageSource(next, driver).should.eventually.eql(XML_ANDROID_TRANSFORMED);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe('findElement(s)', function () {
|
|
30
|
-
const driver = new BaseDriver();
|
|
31
|
-
it('should turn an xpath query into another query run on the original ios source', async function () {
|
|
32
|
-
driver.getPageSource = () => XML_IOS;
|
|
33
|
-
driver.caps = {platformName: 'iOS'};
|
|
34
|
-
// mock out the findElement function to just return an xml node from the fixture
|
|
35
|
-
driver.findElement = (strategy, selector) => {
|
|
36
|
-
const nodes = runQuery(selector, XML_IOS.replace(/<\/?AppiumAUT>/, ''));
|
|
37
|
-
return nodes[0];
|
|
38
|
-
};
|
|
39
|
-
const node = await p.findElement(next, driver, 'xpath', '//TextInput[@axId="username"]');
|
|
40
|
-
getNodeAttrVal(node, 'value').should.eql('alice');
|
|
41
|
-
node.nodeName.should.eql('XCUIElementTypeTextField');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should turn an xpath query into another query run on the original android source', async function () {
|
|
45
|
-
driver.getPageSource = () => XML_ANDROID;
|
|
46
|
-
driver.caps = {platformName: 'Android'};
|
|
47
|
-
driver.opts = {appPackage: 'io.cloudgrey.the_app'};
|
|
48
|
-
driver.findElement = (strategy, selector) => {
|
|
49
|
-
const nodes = runQuery(selector, XML_ANDROID);
|
|
50
|
-
return nodes[0];
|
|
51
|
-
};
|
|
52
|
-
const node = await p.findElement(next, driver, 'xpath', '//TextInput[@axId="username"]');
|
|
53
|
-
getNodeAttrVal(node, 'content-desc').should.eql('username');
|
|
54
|
-
node.nodeName.should.eql('android.widget.EditText');
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import chai from 'chai';
|
|
2
|
-
import { XML_IOS, XML_IOS_TRANSFORMED, XML_IOS_TRANSFORMED_INDEX_PATH,
|
|
3
|
-
XML_IOS_EDGE, XML_IOS_EDGE_TRANSFORMED } from '../fixtures';
|
|
4
|
-
import { transformAttrs, transformChildNodes, transformSourceXml } from '../../lib/source';
|
|
5
|
-
|
|
6
|
-
chai.should();
|
|
7
|
-
|
|
8
|
-
describe('source functions', function () {
|
|
9
|
-
describe('transformSourceXml', function () {
|
|
10
|
-
it('should transform an xml doc based on platform', function () {
|
|
11
|
-
const {xml, unknowns: {nodes, attrs}} = transformSourceXml(XML_IOS, 'ios');
|
|
12
|
-
xml.should.eql(XML_IOS_TRANSFORMED);
|
|
13
|
-
nodes.should.eql([]);
|
|
14
|
-
attrs.should.eql([]);
|
|
15
|
-
});
|
|
16
|
-
it('should transform an xml doc and include index path', function () {
|
|
17
|
-
const {xml, unknowns: {nodes, attrs}} = transformSourceXml(XML_IOS, 'ios', {addIndexPath: true});
|
|
18
|
-
xml.should.eql(XML_IOS_TRANSFORMED_INDEX_PATH);
|
|
19
|
-
nodes.should.eql([]);
|
|
20
|
-
attrs.should.eql([]);
|
|
21
|
-
});
|
|
22
|
-
it('should transform an xml doc and return any unknown nodes or attrs', function () {
|
|
23
|
-
const {xml, unknowns: {nodes, attrs}} = transformSourceXml(XML_IOS_EDGE, 'ios');
|
|
24
|
-
xml.should.eql(XML_IOS_EDGE_TRANSFORMED);
|
|
25
|
-
nodes.should.eql(['SomeRandoElement']);
|
|
26
|
-
attrs.should.eql(['oddAttribute']);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
describe('transformChildNodes', function () {
|
|
30
|
-
it('should loop through child nodes of an object and transform them based on platform', function () {
|
|
31
|
-
const node = {XCUIElementTypeIcon: [{}], XCUIElementTypeKey: [{}], XCUIElementTypeTab: [{}]};
|
|
32
|
-
const metadata = {};
|
|
33
|
-
transformChildNodes(node, Object.keys(node), 'ios', metadata).should.eql({nodes: [], attrs: []});
|
|
34
|
-
node.should.eql({Button: [{}, {}], Icon: [{}]});
|
|
35
|
-
});
|
|
36
|
-
it('should leave unknown nodes intact and add them to unknowns list', function () {
|
|
37
|
-
const node = {XCUIElementTypeIcon: [{}], UnknownThingo: [{}], XCUIElementTypeTab: [{}]};
|
|
38
|
-
const metadata = {};
|
|
39
|
-
transformChildNodes(node, Object.keys(node), 'ios', metadata).should.eql({nodes: ['UnknownThingo'], attrs: []});
|
|
40
|
-
node.should.eql({Button: [{}], UnknownThingo: [{}], Icon: [{}]});
|
|
41
|
-
});
|
|
42
|
-
it('should leave nodes for other platforms intact and add them to unknowns list', function () {
|
|
43
|
-
const node = {XCUIElementTypeIcon: [{}], 'android.widget.EditText': [{}], XCUIElementTypeTab: [{}]};
|
|
44
|
-
const metadata = {};
|
|
45
|
-
transformChildNodes(node, Object.keys(node), 'ios', metadata).should.eql({nodes: ['android.widget.EditText'], attrs: []});
|
|
46
|
-
node.should.eql({Button: [{}], 'android.widget.EditText': [{}], Icon: [{}]});
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
describe('transformAttrs', function () {
|
|
50
|
-
it('should remove attributes in the REMOVE_ATTRS list', function () {
|
|
51
|
-
const obj = {'@_type': 'foo', '@_package': 'yes', '@_class': 'lol'};
|
|
52
|
-
const attrs = Object.keys(obj);
|
|
53
|
-
const unknowns = transformAttrs(obj, attrs, 'ios');
|
|
54
|
-
obj.should.eql({});
|
|
55
|
-
unknowns.should.eql([]);
|
|
56
|
-
});
|
|
57
|
-
it('should translate attributes for the platform', function () {
|
|
58
|
-
const obj = {'@_type': 'foo', '@_resource-id': 'someId'};
|
|
59
|
-
const attrs = Object.keys(obj);
|
|
60
|
-
const unknowns = transformAttrs(obj, attrs, 'android');
|
|
61
|
-
obj.should.eql({'@_id': 'someId'});
|
|
62
|
-
unknowns.should.eql([]);
|
|
63
|
-
});
|
|
64
|
-
it('should not translate unknown attributes and return them in the unknowns list', function () {
|
|
65
|
-
const obj = {'@_type': 'foo', '@_resource-id': 'someId', '@_rando': 'lorian'};
|
|
66
|
-
const attrs = Object.keys(obj);
|
|
67
|
-
const unknowns = transformAttrs(obj, attrs, 'android');
|
|
68
|
-
obj.should.eql({'@_id': 'someId', '@_rando': 'lorian'});
|
|
69
|
-
unknowns.should.eql(['rando']);
|
|
70
|
-
});
|
|
71
|
-
it('should not translate attributes for a different platform', function () {
|
|
72
|
-
const obj = {'@_type': 'foo', '@_resource-id': 'someId'};
|
|
73
|
-
const attrs = Object.keys(obj);
|
|
74
|
-
const unknowns = transformAttrs(obj, attrs, 'ios');
|
|
75
|
-
obj.should.eql({'@_resource-id': 'someId'});
|
|
76
|
-
unknowns.should.eql(['resource-id']);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
});
|
package/test/unit/xpath-specs.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import chai from 'chai';
|
|
2
|
-
import { runQuery, transformQuery, getNodeAttrVal } from '../../lib/xpath';
|
|
3
|
-
import { transformSourceXml } from '../../lib/source';
|
|
4
|
-
import { XML_IOS } from '../fixtures';
|
|
5
|
-
|
|
6
|
-
const should = chai.should();
|
|
7
|
-
|
|
8
|
-
describe('xpath functions', function () {
|
|
9
|
-
describe('runQuery', function () {
|
|
10
|
-
it('should run an xpath query on an XML string and return nodes', function () {
|
|
11
|
-
runQuery('//*', XML_IOS).should.have.length(31);
|
|
12
|
-
runQuery('//XCUIElementTypeTextField', XML_IOS).should.have.length(1);
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
describe('transformQuery', function () {
|
|
16
|
-
it('should transform a query into a single new query', function () {
|
|
17
|
-
const {xml} = transformSourceXml(XML_IOS, 'ios', {addIndexPath: true});
|
|
18
|
-
transformQuery('//TextInput', xml, false)
|
|
19
|
-
.should.eql('/*[1]/*[1]/*[1]/*[1]/*[2]/*[1]/*[1]/*[1]/*[1]/*[1]/*[1]/*[2]/*[1]/*[1]/*[1]');
|
|
20
|
-
});
|
|
21
|
-
it('should transform a query into a multiple new queries if asked', function () {
|
|
22
|
-
const {xml} = transformSourceXml(XML_IOS, 'ios', {addIndexPath: true});
|
|
23
|
-
transformQuery('//Window', xml, true)
|
|
24
|
-
.split('|')
|
|
25
|
-
.should.have.length(2);
|
|
26
|
-
});
|
|
27
|
-
it('should return null for queries that dont find anything', function () {
|
|
28
|
-
const {xml} = transformSourceXml(XML_IOS, 'ios', {addIndexPath: true});
|
|
29
|
-
should.not.exist(transformQuery('//blah', xml, false));
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
describe ('getNodeAttrVal', function () {
|
|
33
|
-
it('should get the attribute for a node', function () {
|
|
34
|
-
const node = runQuery('//XCUIElementTypeTextField', XML_IOS)[0];
|
|
35
|
-
getNodeAttrVal(node, 'name').should.eql('username');
|
|
36
|
-
});
|
|
37
|
-
it('should throw an error if the attr does not exist', function () {
|
|
38
|
-
const node = runQuery('//XCUIElementTypeTextField', XML_IOS)[0];
|
|
39
|
-
should.throw(() => getNodeAttrVal(node, 'foo'));
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|