23
23
import importlib
24
24
import time
25
25
import json
26
+ import platform
26
27
27
28
from .IntegrationTests import IntegrationTests
28
29
from selenium .webdriver .common .by import By
@@ -40,7 +41,30 @@ def setUpClass(cls):
40
41
app = importlib .import_module ('usage-events' ).app
41
42
cls .startServer (cls , app )
42
43
WebDriverWait (cls .driver , 20 ).until (EC .presence_of_element_located ((By .ID , "cytoscape" )))
44
+ cls .actions = ActionChains (cls .driver )
45
+ cls .init_pos = {
46
+ 'Node 1' : (59 , 182 ),
47
+ 'Node 2' : (222 , 345 ),
48
+ 'Node 3' : (168 , 283 - 20 ),
49
+ 'Node 4' : (440 , 182 ),
50
+ 'Node 5' : (277 , 236 ),
51
+ 'Node 6' : (168 , 283 )
52
+ }
43
53
54
+ @classmethod
55
+ def tearDownClass (cls ):
56
+ super (Tests , cls ).tearDownClass ()
57
+
58
+ time .sleep (3 )
59
+ if platform .system () == 'Windows' :
60
+ cls .driver .get ('http://localhost:8050/stop' )
61
+ else :
62
+ cls .server_process .terminate ()
63
+ time .sleep (3 )
64
+ cls .driver .quit ()
65
+
66
+ def tearDown (self ):
67
+ pass
44
68
45
69
def save_screenshot (self , dir_name , name ):
46
70
directory_path = os .path .join (
@@ -130,24 +154,14 @@ def perform_mouseover(self, x, y, elem, actions, dir_name='interactions'):
130
154
131
155
return mouseover_label
132
156
133
- def test_interactions (self ):
134
- # VARIABLES
157
+ def test_dragging (self ):
135
158
drag_error = "Unable to drag Cytoscape nodes properly"
136
- click_error = "Unable to click Cytoscape nodes properly"
137
- mouseover_error = "Unable to mouseover Cytoscape nodes properly"
138
159
139
160
# View module docstring for more information about initial positions
140
- init_pos = {
141
- 'Node 1' : (59 , 182 ),
142
- 'Node 2' : (222 , 345 ),
143
- 'Node 3' : (168 , 283 - 20 ),
144
- 'Node 4' : (440 , 182 ),
145
- 'Node 5' : (277 , 236 ),
146
- 'Node 6' : (168 , 283 )
147
- }
161
+ init_pos = self .init_pos
148
162
init_x , init_y = init_pos ['Node 1' ]
149
163
150
- actions = ActionChains ( self .driver )
164
+ actions = self .actions
151
165
152
166
# Select the JSON output element
153
167
elem_tap = self .driver .find_element_by_css_selector ('pre#tap-node-json-output' )
@@ -164,11 +178,24 @@ def test_interactions(self):
164
178
assert self .perform_dragging (init_x + 150 , init_y + 150 , - 150 , - 150 , elem_tap , actions ) == \
165
179
(- 150 , - 150 ), drag_error
166
180
181
+ def test_clicking (self ):
182
+ click_error = "Unable to click Cytoscape nodes properly"
183
+ actions = self .actions
184
+
185
+ # Select the JSON output element
186
+ elem_tap = self .driver .find_element_by_css_selector ('pre#tap-node-json-output' )
187
+
188
+ init_pos = self .init_pos
167
189
# Test clicking the nodes
168
190
for i in range (1 , 7 ):
169
191
label = 'Node {}' .format (i )
170
192
assert self .perform_clicking (* init_pos [label ], elem_tap , actions ) == label , click_error
171
193
194
+ def test_mouseover (self ):
195
+ init_pos = self .init_pos
196
+ mouseover_error = "Unable to mouseover Cytoscape nodes properly"
197
+ actions = self .actions
198
+
172
199
# Open the Mouseover JSON tab
173
200
actions .move_to_element (
174
201
self .driver .find_element_by_css_selector ('#tabs > div:nth-child(3)' ))
0 commit comments