forked from webdriverio/appium-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDragScreen.ts
79 lines (70 loc) · 2.75 KB
/
DragScreen.ts
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
import AppScreen from './AppScreen';
class DragScreen extends AppScreen {
constructor() {
super('~Drag-drop-screen');
}
get dragL1() {return $('~drag-l1');}
get dragC1() {return $('~drag-c1');}
get dragR1() {return $('~drag-r1');}
get dragL2() {return $('~drag-l2');}
get dragC2() {return $('~drag-c2');}
get dragR2() {return $('~drag-r2');}
get dragL3() {return $('~drag-l3');}
get dragC3() {return $('~drag-c3');}
get dragR3() {return $('~drag-r3');}
get dropL1() {return $('~drop-l1');}
get dropC1() {return $('~drop-c1');}
get dropR1() {return $('~drop-r1');}
get dropL2() {return $('~drop-l2');}
get dropC2() {return $('~drop-c2');}
get dropR2() {return $('~drop-r2');}
get dropL3() {return $('~drop-l3');}
get dropC3() {return $('~drop-c3');}
get dropR3() {return $('~drop-r3');}
private get renew() {return $('~renew');}
private get retry() {return $('~button-Retry');}
async waitForRetryButton(){
return this.retry.waitForDisplayed();
}
async tapOnRetryButton(){
return this.retry.click();
}
async tapOnRenewButton(){
return this.renew.click();
}
async waitForRenewButton(){
return this.renew.waitForDisplayed();
}
/**
* Drag an element to a position.
*/
async dragElementTo(elementOne: WebdriverIO.Element, elementTwo: WebdriverIO.Element) {
await driver.performActions([
{
// 1. Create the event
type: 'pointer',
id: 'finger1',
parameters: { pointerType: 'touch' },
actions: [
// 2. Move finger into start position where the element is
// Appium can automatically determine the location of the element instead
// of doing it ourselves
{ type: 'pointerMove', duration: 0, origin: elementOne.elementId },
// 3. Finger comes down into contact with screen
{ type: 'pointerDown', button: 0 },
// 4. Pause for a little bit
{ type: 'pause', duration: 100 },
// 5. Finger moves to the second element.
// Appium can automatically determine the location of the element instead
// of doing it ourselves
{ type: 'pointerMove', duration: 250, origin: elementTwo.elementId },
// 6. Finger lets up, off the screen
{ type: 'pointerUp', button: 0 },
],
},
]);
// Add a pause, just to make sure the drag and drop is done
await driver.pause(1000);
}
}
export default new DragScreen();