Skip to content

Commit

Permalink
tests: fix some mypy issues after selenium update
Browse files Browse the repository at this point in the history
  • Loading branch information
karlicoss committed Aug 25, 2023
1 parent 01cdfd2 commit c8056d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions tests/end2end_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,8 @@ def open_search_page(self, query: str="") -> None:
)

def move_to(self, element) -> None:
ActionChains(self.driver).move_to_element(element).perform()
# remove type ignore later https://github.com/SeleniumHQ/selenium/pull/12477
ActionChains(self.driver).move_to_element(element).perform() # type: ignore[arg-type]

def switch_to_sidebar(self, wait: Union[bool, int]=False, *, wait2: bool=True) -> None:
raise RuntimeError('not used anymore, use with helper.sidebar instead!')
Expand Down Expand Up @@ -803,7 +804,8 @@ def test_add_to_blacklist_context_menu(tmp_path: Path, browser: Browser) -> None
with get_webdriver(browser=browser) as driver:
configure_extension(driver, port='12345')
driver.get('https://example.com')
chain = webdriver.ActionChains(driver)
# remove type ignore later https://github.com/SeleniumHQ/selenium/pull/12477
chain = webdriver.ActionChains(driver) # type: ignore[arg-type]
chain.move_to_element(driver.find_element(By.TAG_NAME, 'h1')).context_click().perform()

# looks like selenium can't interact with browser context menu...
Expand Down
5 changes: 4 additions & 1 deletion tests/webdriver_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ def frame_context(driver: Driver, frame) -> Iterator[Optional[WebElement]]:
new_frame = get_current_frame(driver)
yield new_frame
finally:
driver.switch_to.frame(current)
# hmm mypy says it can't be None
# but pretty sure it worked when current frame is None?
# see https://github.com/SeleniumHQ/selenium/blob/trunk/py/selenium/webdriver/remote/switch_to.py
driver.switch_to.frame(current) # type: ignore[arg-type]


@contextmanager
Expand Down

0 comments on commit c8056d9

Please sign in to comment.