'How to right-click or move mouse to a element used selenium with python?

For Example: Get icon of google


try:
    element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.TAG_NAME,'body'))
    )
    gmail = driver.find_element(By.LINK_TEXT, 'Gmail')
    google_icon = driver.find_element(By.CLASS_NAME, "lnXdpd")
    action  = ActionChains(driver)
    
    action.context_click(google_icon)

finally:
    pass

the context_click don't work.so I try

    # test second
    action.move_to_element(google_icon)
    # action.context_click(on_element=None)
    action.context_click(google_icon)

It's don't work too. but

gmail.click()

this is can work.what should i do.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source