Broaden KDocs login click and modal capture
This commit is contained in:
@@ -246,14 +246,7 @@ class KDocsUploader:
|
||||
pages = self._iter_pages()
|
||||
clicked = False
|
||||
for page in pages:
|
||||
for name in login_names:
|
||||
if self._try_click_role(page, "button", name):
|
||||
clicked = True
|
||||
break
|
||||
if clicked:
|
||||
continue
|
||||
for name in login_names:
|
||||
if self._try_click_role(page, "link", name):
|
||||
if self._try_click_names(page, login_names):
|
||||
clicked = True
|
||||
break
|
||||
if clicked:
|
||||
@@ -395,6 +388,14 @@ class KDocsUploader:
|
||||
return True
|
||||
if self._try_click_role(page, "link", name, timeout=1200):
|
||||
return True
|
||||
try:
|
||||
el = page.get_by_text(name, exact=True)
|
||||
if el.is_visible(timeout=1200):
|
||||
el.click()
|
||||
time.sleep(1)
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
for frame in page.frames:
|
||||
for name in names:
|
||||
@@ -419,7 +420,11 @@ class KDocsUploader:
|
||||
return False
|
||||
|
||||
def _capture_dialog_image(self, page) -> Optional[bytes]:
|
||||
selectors = "[role='dialog'], .dialog, .modal, .popup"
|
||||
selectors = (
|
||||
"[role='dialog'], .dialog, .modal, .popup, "
|
||||
"div[class*='dialog'], div[class*='modal'], div[class*='popup'], "
|
||||
"div[class*='login'], div[class*='passport'], div[class*='auth']"
|
||||
)
|
||||
try:
|
||||
dialogs = page.locator(selectors)
|
||||
count = min(dialogs.count(), 6)
|
||||
@@ -427,6 +432,9 @@ class KDocsUploader:
|
||||
return None
|
||||
best = None
|
||||
best_area = 0
|
||||
viewport = page.viewport_size or {}
|
||||
vp_width = viewport.get("width", 0)
|
||||
vp_height = viewport.get("height", 0)
|
||||
for i in range(count):
|
||||
el = dialogs.nth(i)
|
||||
try:
|
||||
@@ -435,7 +443,12 @@ class KDocsUploader:
|
||||
box = el.bounding_box()
|
||||
if not box:
|
||||
continue
|
||||
area = box.get("width", 0) * box.get("height", 0)
|
||||
width = box.get("width", 0)
|
||||
height = box.get("height", 0)
|
||||
if vp_width and vp_height:
|
||||
if width > vp_width * 0.92 and height > vp_height * 0.92:
|
||||
continue
|
||||
area = width * height
|
||||
if area > best_area:
|
||||
best_area = area
|
||||
best = el
|
||||
|
||||
Reference in New Issue
Block a user