Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Has anyone used ActionChains of Webdriver(python binding)?

Im trying to trigger mouse over event using move_to_element in ActionChains, Couldn't get it working. Any help is appreciated. Thanks.

like image 275
dmp Avatar asked May 02 '11 15:05

dmp


People also ask

What is ActionChains in Selenium Python?

Selenium's Python Module is built to perform automated testing with Python. ActionChains are a way to automate low-level interactions such as mouse movements, mouse button actions, keypress, and context menu interactions. This is useful for doing more complex actions like hover over and drag and drop.

Is WebDriver interface in Python?

Web Drivers for Using Selenium With PythonSelenium requires a web driver, which will help it interface with the browser that you want to run your tests on. For example, the Firefox browser uses a geckodriver, which you need to install in the right path. The path can be /usr/bin or /usr/local/bin.

Why click is not working in Selenium Python?

Selenium clicks fail when an element is not attached to the current page. Re-find the element if the previously found element has been detached.


1 Answers

from selenium.webdriver.common.action_chains import ActionChains

ActionChains(drivers).move_to_element(drivers.find_element_by_id('element_id')).click().perform()

if you want to select any value,

 menu1 = drivers.find_element_by_xpath('html/path/of/select/box')
 sub_menu0 = drivers.find_element_by_xpath('html/path/of/selected/option')
 clickon = drivers.find_element_by_xpath(path/of/option/where/you/want/to/click)
 action = ActionChains(drivers)
 action.move_to_element(menu1)
 action.move_to_element(sub_menu0)
 action.click(clickon)
 action.perform()
like image 65
Rajan Mandanka Avatar answered Oct 27 '22 01:10

Rajan Mandanka