MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / hover_element_and_click

Function hover_element_and_click

seleniumbase/fixtures/page_actions.py:324–357  ·  view source on GitHub ↗

Similar to hover_and_click(), but assumes top element is already found.

(
    driver,
    element,
    click_selector,
    click_by="css selector",
    timeout=settings.SMALL_TIMEOUT,
)

Source from the content-addressed store, hash-verified

322
323
324def hover_element_and_click(
325 driver,
326 element,
327 click_selector,
328 click_by="css selector",
329 timeout=settings.SMALL_TIMEOUT,
330):
331 """
332 Similar to hover_and_click(), but assumes top element is already found.
333 """
334 _reconnect_if_disconnected(driver)
335 start_ms = time.time() * 1000.0
336 stop_ms = start_ms + (timeout * 1000.0)
337 hover = ActionChains(driver).move_to_element(element)
338 for x in range(int(timeout * 10)):
339 try:
340 hover.perform()
341 element = driver.find_element(by=click_by, value=click_selector)
342 element.click()
343 return element
344 except Exception:
345 now_ms = time.time() * 1000.0
346 if now_ms >= stop_ms:
347 break
348 time.sleep(0.1)
349 plural = "s"
350 if timeout == 1:
351 plural = ""
352 message = "Element {%s} was not present after %s second%s!" % (
353 click_selector,
354 timeout,
355 plural,
356 )
357 timeout_exception(NoSuchElementException, message)
358
359
360def hover_element_and_double_click(

Callers

nothing calls this directly

Calls 5

timeout_exceptionFunction · 0.85
find_elementMethod · 0.45
clickMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…