Skip to content

Commit

Permalink
fix: update dom handling code (#184)
Browse files Browse the repository at this point in the history
* fix: update dom handling code

* Edit comment
  • Loading branch information
Monsterovich authored Oct 20, 2023
1 parent 8a6d684 commit d1c7060
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion deepl/deepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ async def __translate(self, script: str) -> str:
raise DeepLCLIPageLoadError(msg) from e

if self.use_dom_submit:
# banner prevents clicking on language buttons, close the banner first
await page.click("button[data-testid=cookie-banner-lax-close-button]")
# select input / output language
await page.click("button[data-testid=translator-source-lang-btn]")
await page.click(f"button[data-testid=translator-lang-option-{self.fr_lang}]")
Expand All @@ -141,7 +143,7 @@ async def __translate(self, script: str) -> str:
await page.wait_for_function(
"""
() => document.querySelector(
'd-textarea[aria-labelledby=translation-results-heading]')?.value?.length > 0
'd-textarea[aria-labelledby=translation-target-heading]')?.value?.length > 0
""",
)
except PlaywrightError as e:
Expand Down

0 comments on commit d1c7060

Please sign in to comment.