blob: 70f968dc1dc1c400d2635bf31a8c3442b49ac587 (
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
46
47
48
49
50
|
import pytest
from webdriver.error import NoSuchElementException
URL = "https://www.honda.co.uk/cars/book-a-service.html#search?query=tf33bu"
COOKIES_CSS = "#onetrust-accept-btn-handler"
CHOOSE_DEALER_CSS = "a[data-analytics-template*='Make a booking']"
BOOK_ONLINE_CSS = "select#requiredService"
SITE_DOWN_CSS = ".no-results"
async def check_choose_dealer_works(client):
await client.navigate(URL)
cookies = client.css(COOKIES_CSS)
client.await_element(cookies).click()
client.await_element_hidden(cookies)
down, dealer = client.await_first_element_of(
[
client.css(SITE_DOWN_CSS),
client.css(CHOOSE_DEALER_CSS),
],
timeout=5,
)
if down:
pytest.skip("Service is down right now, so testing is impossible")
return True
client.scroll_into_view(dealer)
client.mouse.click(element=dealer).perform()
try:
client.await_css(BOOK_ONLINE_CSS, is_displayed=True, timeout=3)
except NoSuchElementException:
return False
return True
@pytest.mark.skip_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
assert await check_choose_dealer_works(client)
@pytest.mark.skip_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
assert not await check_choose_dealer_works(client)
|