Skip to content

Commit ed4ed20

Browse files
committed
Fix mobile.
1 parent fb51b04 commit ed4ed20

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

tests/acceptance/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ def session_chrome_browser(request, _environment_check):
7070
Create a chrome browser.
7171
"""
7272
headless = request.config.getoption("--headless")
73-
mobile = request.config.getoption("--mobile")
7473

7574
playwright = sync_playwright().start()
7675

@@ -86,6 +85,7 @@ def session_chrome_browser(request, _environment_check):
8685
# Device emulation
8786
context_kwargs = {"viewport": {"width": 1920, "height": 1080}}
8887

88+
mobile = request.config.getoption("--mobile")
8989
if mobile:
9090
context_kwargs = playwright.devices["iPhone SE"]
9191
### user_agent = " ".join(
@@ -125,8 +125,9 @@ def fixture_lute_client(request, chromebrowser):
125125
Start the lute browser.
126126
"""
127127
useport = request.config.getoption("--port")
128+
mobile = request.config.getoption("--mobile")
128129
url = f"http://localhost:{useport}"
129-
c = LuteTestClient(chromebrowser, url)
130+
c = LuteTestClient(chromebrowser, url, mobile)
130131
yield c
131132

132133

tests/acceptance/lute_test_client.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class LuteTestClient: # pylint: disable=too-many-public-methods
2828
################################3
2929
# Setup
3030

31-
def __init__(self, p, home):
31+
def __init__(self, p, home, has_touch=False):
32+
self.has_touch = has_touch
3233
self.page = p
3334
self.home = home
3435
self.visit("dev_api/wipe_db")
@@ -400,11 +401,17 @@ def _get_element_for_word(self, word):
400401
elements = self.page.query_selector_all('span[class*="textitem"]')
401402
es = [e for e in elements if e.text_content() == word]
402403
assert len(es) > 0, f"match for {word}"
404+
# print(f"got match for {word}", flush=True)
403405
return es[0]
404406

405407
def click_word(self, word):
406408
"Click a word in the reading frame."
407-
self._get_element_for_word(word).click()
409+
el = self._get_element_for_word(word)
410+
# print(f"got element {el}", flush=True)
411+
if self.has_touch:
412+
el.tap()
413+
else:
414+
el.click()
408415

409416
def shift_click_words(self, words):
410417
"Shift-click words."

0 commit comments

Comments
 (0)