-
Notifications
You must be signed in to change notification settings - Fork 93
/
test.js
executable file
·116 lines (89 loc) · 2.61 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Get the handle of applications main window
var window = UIATarget.localTarget().frontMostApp().mainWindow();
// Get the handle of view
var view = window.elements()[0];
var textfields = window.textFields();
var passwordfields = window.secureTextFields();
var buttons = window.buttons();
var textviews = window.textViews();
var statictexts = window.staticTexts();
var images = window.images();
var target = UIATarget.localTarget();
// Check number of Text field(s)
if(textfields.length!=0)
{
UIALogger.logFail("FAIL: Invalid number of Text field(s)");
}
else
{
UIALogger.logPass("PASS: Correct number of Text field(s)");
}
// Check number of Secure field(s)
if(passwordfields.length!=0)
{
UIALogger.logFail("FAIL: Invalid number of Secure field(s)");
}
else
{
UIALogger.logPass("PASS: Correct number of Secure field(s)");
}
// Check number of static field(s)
if(statictexts.length!=1)
{
UIALogger.logFail("FAIL: Invalid number of static field(s)");
}
else
{
UIALogger.logPass("PASS: Correct number of static field(s)");
}
// Check number of buttons(s)
if(buttons.length!=3)
{
UIALogger.logFail("FAIL: Invalid number of button(s)");
}
else
{
UIALogger.logPass("PASS: Correct number of button(s)");
}
// Check number of images(s)
if(images.length!=2)
{
UIALogger.logFail("FAIL: Invalid number of image(s)");
}
else
{
UIALogger.logPass("PASS: Correct number of image(s)");
}
UIALogger.logStart("Logging element tree …");
target.logElementTree();
UIALogger.logPass();
//TESTCASE 1 : Successful Log On
if(buttons["signing"]==null || buttons["signin"].toString() == "[object UIAElementNil]")
{
UIALogger.logFail("FAIL:Desired UIButton not found.");
}
else
{
UIALogger.logPass("PASS: Desired UIButton is available");
buttons["signin"].tap();
target.delay(1);
}
/*UIALogger.logStart("Logging element tree …");
window.logElementTree();
UIALogger.logPass();
UIATarget.localTarget().frontMostApp().mainWindow().navigationBar().logElementTree();*/
UIATarget.localTarget().frontMostApp().mainWindow().navigationBar().buttons()[1].tap();
target.delay(1);
UIATarget.localTarget().tap({x:50, y:280});
target.delay(1);
UIATarget.localTarget().frontMostApp().mainWindow().navigationBar().buttons()[0].tap();
target.delay(1);
UIATarget.localTarget().dragFromToForDuration({x:160, y:400}, {x:160, y:200}, 1);
window.scrollViews()[0].logElementTree();
target.delay(1);
UIATarget.localTarget().tap({x:200, y:500});
target.delay(1);
UIATarget.localTarget().tap({x:200, y:250});
target.delay(1);
UIATarget.localTarget().tap({x:200, y:530});
/* window.scrollViews()[0].textViews()["about"].tap(); */