blob: 5a2a51acc1f634fb9590d3296022fce926d9de25 (
plain)
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
|
import time
import pytest
from webdriver.error import ElementClickInterceptedException, NoSuchElementException
URL = "https://www.afisha.ru/msk/theatre/"
COOKIES_CSS = "button.Txfw7"
OPT_CSS = "button[data-name='price']"
SLIDER_CSS = "input[type='range'][data-index='0']"
async def slider_is_clickable(client):
await client.navigate(URL)
try:
client.soft_click(client.await_css(COOKIES_CSS))
client.await_element_hidden(client.css(COOKIES_CSS))
except NoSuchElementException:
pass
try:
client.soft_click(client.await_css(OPT_CSS, is_displayed=True))
except NoSuchElementException:
pytest.xfail("Site may have shown a captcha; please run this test again")
try:
slider = client.await_css(SLIDER_CSS, is_displayed=True)
time.sleep(2)
slider.click()
except ElementClickInterceptedException:
return False
return True
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
assert await slider_is_clickable(client)
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
assert not await slider_is_clickable(client)
|