зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1828953 - add more automated tests for webcompat interventions (mostly Android); r=ksenia DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D176743
This commit is contained in:
Родитель
c7163655f8
Коммит
4a1d78b748
|
@ -75,13 +75,13 @@ class Client:
|
|||
@property
|
||||
def pen(self):
|
||||
return self.session.actions.sequence(
|
||||
"pointer", "pointer_id", {"pointerType": "touch"}
|
||||
"pointer", "pointer_id", {"pointerType": "pen"}
|
||||
)
|
||||
|
||||
@property
|
||||
def touch(self):
|
||||
return self.session.actions.sequence(
|
||||
"pointer", "pointer_id", {"pointerType": "pen"}
|
||||
"pointer", "pointer_id", {"pointerType": "touch"}
|
||||
)
|
||||
|
||||
@property
|
||||
|
@ -333,11 +333,44 @@ class Client:
|
|||
elem = finder.find(self)
|
||||
while time.time() < t0 + timeout:
|
||||
try:
|
||||
if self.is_displayed(elem):
|
||||
time.sleep(delay)
|
||||
if not self.is_displayed(elem):
|
||||
return
|
||||
time.sleep(delay)
|
||||
except webdriver.error.StaleElementReferenceException:
|
||||
return
|
||||
|
||||
def soft_click(self, element):
|
||||
self.execute_script("arguments[0].click()", element)
|
||||
|
||||
def remove_element(self, element):
|
||||
self.execute_script("arguments[0].remove()", element)
|
||||
|
||||
def scroll_into_view(self, element):
|
||||
self.execute_script(
|
||||
"arguments[0].scrollIntoView({block:'center', inline:'center', behavior: 'instant'})",
|
||||
element,
|
||||
)
|
||||
|
||||
def test_for_fastclick(self, element):
|
||||
# FastClick cancels touchend, breaking default actions on Fenix.
|
||||
# It instead fires a mousedown or click, which we can detect.
|
||||
self.execute_script(
|
||||
"""
|
||||
const sel = arguments[0];
|
||||
sel.fastclicked = false;
|
||||
const evt = sel.nodeName === "SELECT" ? "mousedown" : "click";
|
||||
document.addEventListener(evt, e => {
|
||||
if (e.target === sel && !e.isTrusted) {
|
||||
sel.fastclicked = true;
|
||||
}
|
||||
}, true);
|
||||
""",
|
||||
element,
|
||||
)
|
||||
self.scroll_into_view(element)
|
||||
self.touch.click(element=element).perform()
|
||||
return self.execute_script("return arguments[0].fastclicked", element)
|
||||
|
||||
def is_displayed(self, element):
|
||||
if element is None:
|
||||
return False
|
||||
|
@ -348,7 +381,7 @@ class Client:
|
|||
s = window.getComputedStyle(e),
|
||||
v = s.visibility === "visible",
|
||||
o = Math.abs(parseFloat(s.opacity));
|
||||
return e.getClientRects().length && v && (isNaN(o) || o === 1.0);
|
||||
return e.getClientRects().length > 0 && v && (isNaN(o) || o === 1.0);
|
||||
""",
|
||||
args=[element],
|
||||
)
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
import pytest
|
||||
from webdriver.error import NoSuchElementException
|
||||
|
||||
URL = "https://bathpublishing.com/products/clinical-negligence-made-clear-a-guide-for-patients-professionals"
|
||||
POPUP_CSS = "button.recommendation-modal__close-button"
|
||||
SELECT_CSS = "select#productSelect--product-template-option-0"
|
||||
|
||||
|
||||
async def is_fastclick_active(client):
|
||||
await client.navigate(URL)
|
||||
|
||||
try:
|
||||
client.soft_click(client.await_css(POPUP_CSS, timeout=3))
|
||||
client.await_element_hidden(client.css(POPUP_CSS))
|
||||
except NoSuchElementException:
|
||||
pass
|
||||
|
||||
return client.test_for_fastclick(client.await_css(SELECT_CSS))
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
assert not await is_fastclick_active(client)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert await is_fastclick_active(client)
|
|
@ -0,0 +1,23 @@
|
|||
import pytest
|
||||
|
||||
URL = "https://bluetokaicoffee.com/collections/cold-brew-can"
|
||||
SELECT_CSS = "select#SortBy"
|
||||
|
||||
|
||||
async def is_fastclick_active(client):
|
||||
await client.navigate(URL)
|
||||
return client.test_for_fastclick(client.await_css(SELECT_CSS))
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
assert not await is_fastclick_active(client)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert await is_fastclick_active(client)
|
|
@ -0,0 +1,40 @@
|
|||
import pytest
|
||||
from webdriver.error import NoSuchElementException
|
||||
|
||||
URL = "https://www.co2meter.com/collections/restaurants-food"
|
||||
ITEM_CSS = "a.grid__image"
|
||||
ADD_CSS = "#AddToCart"
|
||||
SELECT_CSS = "select#address_country"
|
||||
POPUP_CLOSE_CSS = "button.needsclick.klaviyo-close-form"
|
||||
|
||||
|
||||
async def is_fastclick_active(client):
|
||||
await client.navigate(URL)
|
||||
|
||||
client.soft_click(client.await_css(ITEM_CSS))
|
||||
client.soft_click(client.await_css(ADD_CSS))
|
||||
|
||||
try:
|
||||
popup_close_finder = client.css(POPUP_CLOSE_CSS)
|
||||
popup_close = client.await_element(popup_close_finder, timeout=5)
|
||||
if popup_close:
|
||||
client.soft_click(popup_close)
|
||||
client.await_element_hidden(popup_close_finder)
|
||||
except NoSuchElementException:
|
||||
pass
|
||||
|
||||
return client.test_for_fastclick(client.await_css(SELECT_CSS))
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
assert not await is_fastclick_active(client)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert await is_fastclick_active(client)
|
|
@ -0,0 +1,23 @@
|
|||
import pytest
|
||||
|
||||
URL = "https://www.discountcoffee.co.uk/collections/wholesale-coffee-beans"
|
||||
SELECT_CSS = "#collection-filter-type select"
|
||||
|
||||
|
||||
async def is_fastclick_active(client):
|
||||
await client.navigate(URL)
|
||||
return client.test_for_fastclick(client.await_css(SELECT_CSS))
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
assert not await is_fastclick_active(client)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert await is_fastclick_active(client)
|
|
@ -0,0 +1,23 @@
|
|||
import pytest
|
||||
|
||||
URL = "https://dylantalkstone.com/collections/tele-pickups/products/flat-6-tele-pickups"
|
||||
SELECT_CSS = "select#productSelect-option-0"
|
||||
|
||||
|
||||
async def is_fastclick_active(client):
|
||||
await client.navigate(URL)
|
||||
return client.test_for_fastclick(client.await_css(SELECT_CSS))
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
assert not await is_fastclick_active(client)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert await is_fastclick_active(client)
|
|
@ -0,0 +1,23 @@
|
|||
import pytest
|
||||
|
||||
URL = "https://www.fourbarrelcoffee.com/"
|
||||
ADD_TO_CART_CSS = "#container a#menu-link"
|
||||
|
||||
|
||||
async def is_fastclick_active(client):
|
||||
await client.navigate(URL)
|
||||
return client.test_for_fastclick(client.await_css(ADD_TO_CART_CSS))
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
assert not await is_fastclick_active(client)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert await is_fastclick_active(client)
|
|
@ -0,0 +1,23 @@
|
|||
import pytest
|
||||
|
||||
URL = "https://products.franmar.com/collections/consumer-products/"
|
||||
SELECT_CSS = "#sortBy"
|
||||
|
||||
|
||||
async def is_fastclick_active(client):
|
||||
await client.navigate(URL)
|
||||
return client.test_for_fastclick(client.await_css(SELECT_CSS))
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
assert not await is_fastclick_active(client)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert await is_fastclick_active(client)
|
|
@ -0,0 +1,23 @@
|
|||
import pytest
|
||||
|
||||
URL = "https://gofreeconcepts.de/collections/shamma-sandals/products/shamma-sandals-warriors-maximus-mit-lederfussbett"
|
||||
SELECT_CSS = "#productSelect"
|
||||
|
||||
|
||||
async def is_fastclick_active(client):
|
||||
await client.navigate(URL)
|
||||
return client.test_for_fastclick(client.await_css(SELECT_CSS))
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
assert not await is_fastclick_active(client)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert await is_fastclick_active(client)
|
|
@ -0,0 +1,23 @@
|
|||
import pytest
|
||||
|
||||
URL = "https://renewd.com.au"
|
||||
ADD_TO_CART_CSS = "button[id].btn.add_to_cart"
|
||||
|
||||
|
||||
async def is_fastclick_active(client):
|
||||
await client.navigate(URL)
|
||||
return client.test_for_fastclick(client.await_css(ADD_TO_CART_CSS))
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
assert not await is_fastclick_active(client)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert await is_fastclick_active(client)
|
|
@ -0,0 +1,31 @@
|
|||
import pytest
|
||||
from webdriver.error import NoSuchElementException
|
||||
|
||||
URL = "https://thehawksmoor.com/book-a-table/?location=11335"
|
||||
POPUP_CSS = ".pum-overlay button.pum-close"
|
||||
SELECT_CSS = "select#booktable_restaurants"
|
||||
|
||||
|
||||
async def is_fastclick_active(client):
|
||||
await client.navigate(URL)
|
||||
|
||||
try:
|
||||
client.soft_click(client.await_css(POPUP_CSS, timeout=3))
|
||||
except NoSuchElementException:
|
||||
pass
|
||||
|
||||
return client.test_for_fastclick(client.await_css(SELECT_CSS))
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
assert not await is_fastclick_active(client)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert await is_fastclick_active(client)
|
|
@ -0,0 +1,26 @@
|
|||
import pytest
|
||||
|
||||
URL = (
|
||||
"https://m.tailieu.vn/index/mobile/id/1654340/hash/654d7ea9c2853e5be07e2c792ea7f168"
|
||||
)
|
||||
PAGE_CSS = "#viewer > #pageContainer1"
|
||||
OK_ERROR_CSS = "#errorMessage"
|
||||
ERROR_MSG = "may not load data from http://tailieu.vn/html5/pdf.js"
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
await client.navigate(URL)
|
||||
page, ok_error = client.await_first_element_of(
|
||||
[client.css(PAGE_CSS), client.css(OK_ERROR_CSS)], is_displayed=True
|
||||
)
|
||||
assert page or ok_error
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
await client.navigate(URL, await_console_message=ERROR_MSG)
|
|
@ -10,7 +10,7 @@ DESKTOP_CSS = "#cbiBody"
|
|||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
await client.navigate(URL)
|
||||
assert client.find_css(MOBILE_CSS)
|
||||
assert client.await_css(MOBILE_CSS)
|
||||
assert not client.find_css(DESKTOP_CSS)
|
||||
|
||||
|
||||
|
@ -19,5 +19,5 @@ async def test_enabled(client):
|
|||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
await client.navigate(URL)
|
||||
assert client.find_css(DESKTOP_CSS)
|
||||
assert client.await_css(DESKTOP_CSS)
|
||||
assert not client.find_css(MOBILE_CSS)
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
import pytest
|
||||
|
||||
URL = "https://www.yebocasino.co.za/webplay/"
|
||||
PRACTICE_CSS = "#lobbybox_featuredgames .gamebox .cta.practice"
|
||||
IFRAME_CSS = "#gameiframe"
|
||||
UNSUPPORTED_CSS = ".unsupported-device-box"
|
||||
SUPPORTED_CSS = "#game_main"
|
||||
|
||||
|
||||
async def get_to_page(client):
|
||||
await client.navigate(URL)
|
||||
client.soft_click(client.await_css(PRACTICE_CSS))
|
||||
client.switch_to_frame(client.await_css(IFRAME_CSS))
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
await get_to_page(client)
|
||||
assert client.await_css(SUPPORTED_CSS)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
await get_to_page(client)
|
||||
assert client.await_css(UNSUPPORTED_CSS)
|
|
@ -0,0 +1,25 @@
|
|||
import pytest
|
||||
|
||||
URL = "https://www.renaud-bray.com/accueil.aspx"
|
||||
ERROR_MSG = "ua.split(...)[1] is undefined"
|
||||
MENU_CSS = "#pageHeader_menuStores"
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
await client.navigate(URL)
|
||||
assert client.execute_script(
|
||||
"""
|
||||
return arguments[0].style.zIndex == "7000";
|
||||
""",
|
||||
client.await_css(MENU_CSS),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
await client.navigate(URL, await_console_message=ERROR_MSG)
|
|
@ -0,0 +1,42 @@
|
|||
import pytest
|
||||
from webdriver.error import NoSuchElementException
|
||||
|
||||
URL = "https://veniceincoming.com/it_IT/search_results?page=1&start_date_start=&start_date_end=&k="
|
||||
COOKIES_CSS = "[aria-label='cookieconsent'] .cc-allow"
|
||||
IMG_CSS = ".tour-details"
|
||||
TOUR_DATA_CSS = "#tour_data"
|
||||
|
||||
|
||||
async def check_filter_opens(client):
|
||||
await client.navigate(URL)
|
||||
|
||||
try:
|
||||
cookies = client.await_css(COOKIES_CSS, is_displayed=True, timeout=5)
|
||||
client.soft_click(cookies)
|
||||
client.await_element_hidden(client.css(COOKIES_CSS))
|
||||
except NoSuchElementException:
|
||||
pass
|
||||
|
||||
img = client.await_css(IMG_CSS)
|
||||
client.scroll_into_view(img)
|
||||
client.mouse.click(element=img).perform()
|
||||
|
||||
try:
|
||||
client.await_css(TOUR_DATA_CSS, is_displayed=True, timeout=5)
|
||||
except NoSuchElementException:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
assert await check_filter_opens(client)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert not await check_filter_opens(client)
|
|
@ -5,7 +5,7 @@ import pytest
|
|||
|
||||
URL = "https://www.coldwellbankerhomes.com/ri/little-compton/kvc-17_1,17_2/"
|
||||
ERROR_MSG = 'can\'t access property "dataset", v[0] is undefined'
|
||||
SUCCESS_CSS = "img[src='https://m.cbhomes.com/p/412/1333515/48cd7692a01247A/s23cc.jpg']"
|
||||
SUCCESS_CSS = "img.psr-lazy:not([src*='spacer'])"
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import pytest
|
||||
|
||||
URL = "https://www.china-airlines.com/tw/en/booking/book-flights/flight-search?lang=en-us&deptstn=TPE&arrstn=LAX"
|
||||
DATE_CSS = "#departureDateMobile"
|
||||
DATE_DISABLED_CSS = "#departureDateMobile[disabled]"
|
||||
|
||||
|
||||
async def check_date_disabled(client):
|
||||
await client.navigate(URL)
|
||||
client.await_css(DATE_CSS)
|
||||
return client.find_css(DATE_DISABLED_CSS)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
assert not await check_date_disabled(client)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert await check_date_disabled(client)
|
|
@ -0,0 +1,31 @@
|
|||
import pytest
|
||||
from webdriver.error import NoSuchElementException
|
||||
|
||||
URL = "https://mobilevikings.be/en/registration/?product_id=155536813-1-1"
|
||||
COOKIES_CSS = "#btn-accept-cookies"
|
||||
DATE_CSS = "input.date-input[name='birth_date']"
|
||||
|
||||
|
||||
async def date_after_typing(client):
|
||||
await client.navigate(URL)
|
||||
try:
|
||||
client.await_css(COOKIES_CSS, timeout=3).click()
|
||||
client.await_element_hidden(client.css(COOKIES_CSS))
|
||||
except NoSuchElementException:
|
||||
pass
|
||||
date = client.await_css(DATE_CSS)
|
||||
client.scroll_into_view(date)
|
||||
date.send_keys("1")
|
||||
return date.property("value")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
assert "1_/__/____" == await date_after_typing(client)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert "__/__/____" == await date_after_typing(client)
|
|
@ -0,0 +1,21 @@
|
|||
import pytest
|
||||
|
||||
URL = "https://www.samsung.com/in/watches/galaxy-watch/galaxy-watch5-44mm-graphite-bluetooth-sm-r910nzaainu/"
|
||||
GOOD_CSS = "html.linux.firefox"
|
||||
ERROR_MSG = "DOMTokenList.add: The empty string is not a valid token."
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("linux")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
await client.navigate(URL)
|
||||
assert client.await_css(GOOD_CSS)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("linux")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
await client.navigate(URL, await_console_message=ERROR_MSG)
|
||||
assert not client.find_css(GOOD_CSS)
|
|
@ -0,0 +1,45 @@
|
|||
import pytest
|
||||
from webdriver.error import NoSuchElementException
|
||||
|
||||
URL = "https://www.vivobarefoot.com/eu/mens"
|
||||
FILTER_CSS = "#narrow-by-list .filter-wrapper:last-of-type"
|
||||
SUBMENU_CSS = "#narrow-by-list .filter-wrapper:last-of-type dd"
|
||||
POPUP1_CSS = "#globalePopupWrapper"
|
||||
POPUP2_CSS = "#globale_overlay"
|
||||
POPUP3_CSS = ".weblayer--box-subscription-1"
|
||||
|
||||
|
||||
async def check_filter_opens(client):
|
||||
await client.navigate(URL)
|
||||
|
||||
popup = client.await_css(POPUP1_CSS, timeout=3)
|
||||
if popup:
|
||||
client.remove_element(popup)
|
||||
popup = client.find_css(POPUP2_CSS)
|
||||
if popup:
|
||||
client.remove_element(popup)
|
||||
popup = client.find_css(POPUP3_CSS)
|
||||
if popup:
|
||||
client.remove_element(popup)
|
||||
|
||||
filter = client.await_css(FILTER_CSS)
|
||||
client.mouse.click(element=filter).perform()
|
||||
try:
|
||||
client.await_css(SUBMENU_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_filter_opens(client)
|
||||
|
||||
|
||||
@pytest.mark.skip_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert not await check_filter_opens(client)
|
|
@ -0,0 +1,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)
|
|
@ -0,0 +1,33 @@
|
|||
import pytest
|
||||
from webdriver.error import NoSuchElementException
|
||||
|
||||
URL = (
|
||||
"https://www.marksandspencer.com/webapp/wcs/stores/servlet/GenericApplicationError"
|
||||
)
|
||||
COOKIES_CSS = "button.navigation-cookiebbanner__submit"
|
||||
SELECT_CSS = "#progressiveHeaderSection button.navigation-hamburger-trigger"
|
||||
|
||||
|
||||
async def is_fastclick_active(client):
|
||||
await client.navigate(URL)
|
||||
try:
|
||||
client.await_css(COOKIES_CSS, timeout=3).click()
|
||||
client.await_element_hidden(client.css(COOKIES_CSS))
|
||||
except NoSuchElementException:
|
||||
pass
|
||||
|
||||
return client.test_for_fastclick(client.await_css(SELECT_CSS))
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
assert not await is_fastclick_active(client)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert await is_fastclick_active(client)
|
|
@ -0,0 +1,26 @@
|
|||
import pytest
|
||||
|
||||
URL = "https://www.wellcare.com/en/Oregon/Members/Prescription-Drug-Plans-2023/Wellcare-Value-Script"
|
||||
MENU_CSS = "a[title='login DDL']"
|
||||
SELECT_CSS = "select#userSelect"
|
||||
|
||||
|
||||
async def is_fastclick_active(client):
|
||||
await client.navigate(URL)
|
||||
menu = client.await_css(MENU_CSS)
|
||||
menu.click()
|
||||
return client.test_for_fastclick(client.await_css(SELECT_CSS))
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
assert not await is_fastclick_active(client)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
assert await is_fastclick_active(client)
|
|
@ -0,0 +1,21 @@
|
|||
import pytest
|
||||
|
||||
URL = "https://www.cmbchina.com/"
|
||||
DESKTOP_CSS = "#aspnetForm"
|
||||
MOBILE_CSS = "#app .mobile-header"
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
await client.navigate(URL)
|
||||
assert client.await_css(MOBILE_CSS)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
await client.navigate(URL)
|
||||
assert client.await_css(DESKTOP_CSS)
|
|
@ -0,0 +1,18 @@
|
|||
import pytest
|
||||
|
||||
URL = "https://www.axisbank.com/retail/cards/credit-card"
|
||||
SITE_CSS = "#ulCreditCard:not(:empty)"
|
||||
ERROR_MSG = "webkitSpeechRecognition is not defined"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
await client.navigate(URL)
|
||||
assert client.await_css(SITE_CSS)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
await client.navigate(URL, await_console_message=ERROR_MSG)
|
|
@ -0,0 +1,21 @@
|
|||
import pytest
|
||||
|
||||
URL = "https://feelgoodcontacts.com/"
|
||||
MOBILE_CSS = "#aHomeMob"
|
||||
DESKTOP_CSS = "#mmenu"
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_enabled(client):
|
||||
await client.navigate(URL)
|
||||
assert client.await_css(MOBILE_CSS)
|
||||
|
||||
|
||||
@pytest.mark.only_platforms("android")
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
await client.navigate(URL)
|
||||
assert client.await_css(DESKTOP_CSS)
|
Загрузка…
Ссылка в новой задаче