Skip to content

Commit 9475eba

Browse files
committed
Better drag game
1 parent a01327e commit 9475eba

8 files changed

Lines changed: 276 additions & 220 deletions

File tree

atest/test/02_Content_Keywords/basic_getters.robot

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ Get Attribute Names And Assert Single And Multiple
120120

121121
Get Classes
122122
[Setup] Ensure Location ${LOGIN_URL}
123-
${classes} = Get Classes id=draggable
124-
Should Be Equal ${classes} ${{["box", "react-draggable"]}}
123+
${classes} = Get Classes id=ManyClass
124+
Should Be Equal ${classes} ${{["pure-button", "another", "something", "kala"]}}
125125

126126
Get Classes With Strict
127127
[Tags] slow
@@ -136,13 +136,12 @@ Get Classes With Strict
136136

137137
Get Classes And Assert
138138
[Setup] Ensure Location ${LOGIN_URL}
139-
Get Classes id=draggable contains react-draggable
140-
Get Classes id=draggable == react-draggable box
141-
Get Classes id=draggable validate "react-draggable-dragged" not in value
142-
Drag And Drop Relative To id=draggable 10 10 steps=2
143-
Get Classes id=draggable *= react-draggable box
144-
Get Classes id=draggable == react-draggable box react-draggable-dragged
145-
Get Classes id=draggable validate "react-draggable-dragged" in value
139+
Get Classes id=ManyClass contains another
140+
Get Classes id=ManyClass == pure-button another something kala
141+
Get Classes id=ManyClass validate "tidii" not in value
142+
Get Classes id=ManyClass *= pure-button another
143+
Get Classes id=ManyClass == pure-button another something kala
144+
Get Classes id=ManyClass validate "another" in value
146145

147146
Get Element Count
148147
[Setup] Ensure Location ${LOGIN_URL}

atest/test/02_Content_Keywords/basic_getters_expect_errors.robot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,16 @@ Get Attribute Names Custom Error
233233

234234
Get Classes Default Error
235235
Run Keyword And Expect Error
236-
... EQUALS: Classes of ${SELECTOR_PREFIX_SPACED}id=draggable '['box', 'react-draggable']' (list) should contain '['not-here']' (list)
236+
... EQUALS: Classes of id=ManyClass '['pure-button', 'another', 'something', 'kala']' (list) should contain '['not-here']' (list)
237237
... Get Classes
238-
... id=draggable
238+
... id=ManyClass
239239
... contains
240240
... not-here
241241

242242
Get Classes Custom Error
243243
Run Keyword And Expect Error
244244
... My Custom Error
245-
... Get Classes id=draggable contains not-here message=My Custom Error
245+
... Get Classes id=ManyClass contains not-here message=My Custom Error
246246

247247
Get Element Count Default Error
248248
Run Keyword And Expect Error

atest/test/02_Content_Keywords/solve_draggame.robot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Test Setup New Page ${DRAGGAME_URL}
77
Move Obstacle To Goal And Make A Goal
88
Get Text h2 == Put the circle in the goal
99
Drag And Drop id=blue-box id=invisible-element steps=10
10-
Drag And Drop id=red-circle id=goal steps=10
10+
Drag And Drop id=red-circle id=goal-post steps=10
1111
Get Text h2 == GOAL!!!
1212

1313
Move Obstacle Away And Drag And Drop
@@ -16,7 +16,7 @@ Move Obstacle Away And Drag And Drop
1616
Mouse Button down
1717
Mouse Move Relative To id=blue-box 200
1818
Mouse Button up
19-
Drag And Drop id=red-circle id=goal steps=10
19+
Drag And Drop id=red-circle id=goal-post steps=10
2020
Get Text h2 == GOAL!!!
2121

2222
Test

atest/test/02_Content_Keywords/virtual_mouse.robot

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,26 @@ Move In Circle
2222
Mouse Move 0 0
2323

2424
Draggable Test
25-
${x} = Get Boundingbox \#draggable x
26-
${y} = Get Boundingbox \#draggable y
25+
[Setup] New Page ${DRAGGAME_URL}
26+
${x} = Get Boundingbox id=blue-box x
27+
${y} = Get Boundingbox id=blue-box y
2728
# evaluate end coordinates
28-
${xnew} = Evaluate ${x}+400
29-
${ynew} = Evaluate ${y}+400
29+
${xnew} = Evaluate ${x}-200
30+
${ynew} = Evaluate ${y}-200
3031
Mouse Button down ${x} ${y}
3132
Mouse Button up ${xnew} ${ynew}
3233
# just do a random move to make sure the element is not stuck to mouse any more
3334
Mouse Move 0 0
34-
Get Text \#dragX == 400
35-
Get Text \#dragY == 400
35+
Get Text id=blue-box-x-value == 360
36+
Get Text id=blue-box-y-value == 80
37+
3638

3739
Drag And Drop
38-
Drag And Drop id=draggable id=clickWithOptions
39-
${obj_center} = Get Boundingbox id=draggable ALL evaluate ${Center_Func}
40-
${dest_center} = Get Boundingbox id=clickWithOptions ALL evaluate ${Center_Func}
40+
[Setup] New Page ${DRAGGAME_URL}
41+
Drag And Drop id=blue-box id=invisible-element
42+
Take Screenshot
43+
${dest_center} = Get Boundingbox id=invisible-element ALL evaluate ${Center_Func} allow_hidden=True
44+
Take Screenshot
4145
Assert Position ${dest_center}[x] ${dest_center}[y] ${tol}
4246

4347
Drag And Drop With Strict
@@ -47,34 +51,37 @@ Drag And Drop With Strict
4751
... Drag And Drop //input id=clickWithOptions
4852
Run Keyword And Expect Error
4953
... *strict mode violation*//input*resolved to ${INPUT_ELEMENT_COUNT_IN_LOGIN} elements*
50-
... Drag And Drop id=draggable //input
54+
... Drag And Drop id=clickWithOptions //input
5155
Set Strict Mode False
52-
Drag And Drop id=draggable //input
56+
Drag And Drop id=clickWithOptions //input
5357
Drag And Drop //input id=clickWithOptions
5458
[Teardown] Set Strict Mode True
5559

5660
Drag And Drop With Coordinates
5761
[Tags] slow
5862
[Timeout] 60s
59-
${obj_center} = Get Boundingbox id=draggable ALL evaluate ${Center_Func}
60-
${obj_dim} = Get Boundingbox id=draggable ALL evaluate ${Dim_Func}
61-
${dest_center} = Get Boundingbox id=clickWithOptions ALL evaluate ${Center_Func}
63+
[Setup] New Page ${DRAGGAME_URL}
64+
${obj_center} = Get Boundingbox id=blue-box ALL evaluate ${Center_Func}
65+
${obj_dim} = Get Boundingbox id=blue-box ALL evaluate ${Dim_Func}
66+
${dest_center} = Get Boundingbox id=goal-post ALL evaluate ${Center_Func}
6267
# Tests with implicit argument drop=True
6368
Drag And Drop By Coordinates
6469
... from_x=${obj_center}[x] from_y=${obj_center}[y]
6570
... to_x=${dest_center}[x] to_y=${dest_center}[y] steps=200
6671
Assert Position ${dest_center}[x] ${dest_center}[y] ${tol}
72+
Take Screenshot
6773
Drag And Drop By Coordinates
6874
... from_x=${dest_center}[x] from_y=${dest_center}[y]
6975
... to_x=${obj_center}[x] to_y=${obj_center}[y] steps=200
76+
Take Screenshot
7077
Assert Position ${obj_center}[x] ${obj_center}[y] ${tol}
7178
# Tests with explicit values True or False for argument drop
72-
# "Start coordinates" of draggable object:
79+
# "Start coordinates" of blue-box object:
7380
${x1} = Set Variable ${obj_center}[x]
7481
${y1} = Set Variable ${obj_center}[y]
7582
${width} = Set Variable ${obj_dim}[width]
7683
${height} = Set Variable ${obj_dim}[height]
77-
Log Draggable object: ${obj_center}
84+
Log blue-box object: ${obj_center}
7885
# coordinates where to drag in relative values:
7986
${x2} = Evaluate ${x1} + 0.1 * ${width}
8087
${y2} = Evaluate ${y1} - 1.0 * ${height}
@@ -88,12 +95,19 @@ Drag And Drop With Coordinates
8895
${time} = Set Variable 1
8996

9097
Hover And Drop To Hover
91-
Hover id=draggable 10 10
98+
[Setup] New Page ${DRAGGAME_URL}
99+
${x} Get Text id=blue-box-x-value
100+
${y} Get Text id=blue-box-y-value
101+
Hover id=blue-box 10 10
92102
Mouse Button down
93-
Hover id=draggable 30 40
103+
Hover id=blue-box 30 40
94104
Mouse Button up
95-
Get Text \#dragX == 20
96-
Get Text \#dragY == 30
105+
${x} Evaluate ${x}+30
106+
${y} Evaluate ${y}+40
107+
${x} Convert To String ${x}
108+
${y} Convert To String ${y}
109+
Get Text id=blue-box-x-value == ${x}
110+
Get Text id=blue-box-y-value == ${y}
97111

98112
Hover With Strict
99113
Set Strict Mode True
@@ -105,16 +119,18 @@ Hover With Strict
105119
[Teardown] Set Strict Mode True
106120

107121
Drag And Drop With Move Relative
108-
Relative DnD 32 64 32 64
109-
Relative DnD 0 -64 32 0
110-
Relative DnD -20 0 12 0
111-
Relative DnD -22 -20 -10 -20
122+
[Setup] New Page ${DRAGGAME_URL}
123+
Relative DnD 32 64 672 424
124+
Relative DnD 0 -64 752 440
125+
Relative DnD -20 0 812 520
126+
Relative DnD -22 -20 870 580
112127

113128
Drag And Drop Relative To
114-
DnD Relative To 32 64 32 64
115-
DnD Relative To 0 -64 32 0
116-
DnD Relative To -20 0 12 0
117-
DnD Relative To -22 -20 -10 -20
129+
[Setup] New Page ${DRAGGAME_URL}
130+
DnD Relative To 32 64 672 424
131+
DnD Relative To 0 -64 752 440
132+
DnD Relative To -20 0 812 520
133+
DnD Relative To -22 -20 870 580
118134

119135
Click Count
120136
${x} = Get Boundingbox \#clickWithOptions x
@@ -172,15 +188,15 @@ Scroll By Mouse Wheel
172188
*** Keywords ***
173189
Relative DnD
174190
[Arguments] ${x} ${y} ${txt_x} ${txt_y}
175-
Hover id=draggable
191+
Hover id=blue-box
176192
Mouse Button down
177-
Mouse Move Relative To id=draggable ${x} ${y} steps=2
193+
Mouse Move Relative To id=blue-box ${x} ${y} steps=2
178194
Mouse Button up
179-
Get Text \#dragX == ${txt_x}
180-
Get Text \#dragY == ${txt_y}
195+
Get Text id=blue-box-x-value == ${txt_x}
196+
Get Text id=blue-box-y-value == ${txt_y}
181197

182198
DnD Relative To
183199
[Arguments] ${x} ${y} ${txt_x} ${txt_y}
184-
Drag And Drop Relative To id=draggable ${x} ${y} steps=2
185-
Get Text id=dragX == ${txt_x}
186-
Get Text id=dragY == ${txt_y}
200+
Drag And Drop Relative To id=blue-box ${x} ${y} steps=2
201+
Get Text id=blue-box-x-value == ${txt_x}
202+
Get Text id=blue-box-y-value == ${txt_y}

atest/test/keywords.resource

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ Assert Position
7575
... {'x': (value["x"] + (value["width"] / 2)), 'y': (value["y"] + (value["height"] / 2))}
7676
${Node_Func} = Set Variable
7777
... {'x': (value["x"]), 'y': (value["y"])}
78-
${obj_node} = Get Boundingbox id=draggable ALL evaluate ${Node_Func}
79-
${obj_center} = Get Boundingbox id=draggable ALL evaluate ${Center_Func}
80-
${x_diff} = Evaluate ${obj_center}[x] - ${expect_x}
81-
${y_diff} = Evaluate ${obj_center}[y] - ${expect_y}
78+
${obj_node} = Get Boundingbox id=blue-box ALL evaluate ${Node_Func}
79+
${obj_center} = Get Boundingbox id=blue-box ALL evaluate ${Center_Func}
80+
${x_diff} = Evaluate ${obj_node}[x] - ${expect_x}
81+
${y_diff} = Evaluate ${obj_node}[y] - ${expect_y}
8282
Log Many Node x,y: \t${obj_node}[x],\t${obj_node}[y]
8383
... Center x,y: \t${obj_center}[x],\t${obj_center}[y]\nExpected xy \t${expect_x},\t${expect_y}
8484
... X-Diff: ${x_diff}, Y-Diff: ${y_diff}, tolerance: ${tol}

node/dynamic-test-app/src/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import DragGame from './draggame';
21
import { HashRouter, Route, Routes } from 'react-router-dom';
2+
import DragGame from './draggame';
33
import Login from './login';
44
import React from 'react';
55

0 commit comments

Comments
 (0)