-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathtest_actions.py
42 lines (30 loc) · 1.1 KB
/
test_actions.py
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
from time import time
from selenium.webdriver import Keys, ActionChains
from selenium.webdriver.common.actions.action_builder import ActionBuilder
from selenium.webdriver.common.by import By
def test_pauses(driver):
driver.get('https://selenium.dev/selenium/web/mouse_interaction.html')
start = time()
clickable = driver.find_element(By.ID, "clickable")
ActionChains(driver)\
.move_to_element(clickable)\
.pause(1)\
.click_and_hold()\
.pause(1)\
.send_keys("abc")\
.perform()
duration = time() - start
assert duration > 2
assert duration < 3
def test_releases_all(driver):
driver.get('https://selenium.dev/selenium/web/mouse_interaction.html')
clickable = driver.find_element(By.ID, "clickable")
ActionChains(driver)\
.click_and_hold(clickable)\
.key_down(Keys.SHIFT)\
.key_down("a")\
.perform()
ActionBuilder(driver).clear_actions()
ActionChains(driver).key_down('a').perform()
assert clickable.get_attribute('value')[0] == "A"
assert clickable.get_attribute('value')[1] == "a"