forked from cobrateam/splinter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmouse_interaction.py
More file actions
68 lines (57 loc) · 2.67 KB
/
mouse_interaction.py
File metadata and controls
68 lines (57 loc) · 2.67 KB
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
# -*- coding: utf-8 -*-
# Copyright 2012 splinter authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
import warnings
from .fake_webapp import EXAMPLE_APP
class MouseInteractionTest(object):
def test_mouse_over(self):
"Should be able to perform a mouse over on an element"
self.browser.visit(EXAMPLE_APP)
self.browser.find_by_css(".add-element-mouseover").mouse_over()
self.assertTrue(self.browser.is_element_present_by_id('what-is-your-name'))
self.browser.find_by_css(".add-element-mouseover").mouse_out()
def test_mouse_out(self):
"Should be able to perform a mouse out on an element"
self.browser.visit(EXAMPLE_APP)
element = self.browser.find_by_css(".add-element-mouseover")
element.mouse_over()
element.mouse_out()
self.assertFalse(self.browser.is_element_present_by_id('what-is-your-name'))
def test_double_click(self):
"double click should shows a hidden element"
self.browser.visit(EXAMPLE_APP)
button = self.browser.find_by_css(".db-button")
button.double_click()
element = self.browser.find_by_css(
".should-be-visible-after-double-click"
)
self.assertTrue(element.visible)
self.assertTrue(self.browser.is_element_not_present_by_id('what-is-your-name'))
def test_right_click(self):
"should be able to perform a right click on an element"
self.browser.visit(EXAMPLE_APP)
element = self.browser.find_by_css(".right-clicable")
element.right_click()
self.assertEqual(
self.browser.find_by_css('.right-clicable').text,
'right clicked'
)
def test_drag_and_drop(self):
"""
should be able to perform a drag an element and drop in another element
"""
droppable = self.browser.find_by_css('.droppable')
draggable = self.browser.find_by_css('.draggable')
draggable.drag_and_drop(droppable)
self.assertEqual(self.browser.find_by_css('.dragged').text, 'yes')
def test_mouseover_should_be_an_alias_to_mouse_over(self):
"mouseover should be an alias to mouse_over and be deprecated"
with warnings.catch_warnings(record=True) as warnings_list:
self.browser.visit(EXAMPLE_APP)
warnings.simplefilter("always")
element = self.browser.find_by_css(".add-element-mouseover")
element.mouseover()
warn_message = warnings_list[-1].message
self.assertIsInstance(warn_message, DeprecationWarning)
self.assertIn('mouse_over', warn_message.args[0])