ActionChains are used to automate interactions like mouse movement, mouse button action, key press, context menu, drag and drop etc. These are typically complex operations which can't be performed directly with web driver elements. Using ActionChains objects, specified actions are pushed into a queue and perform operation is called to execute these one by one. Example 1 : Context Menu from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.by import By import time CHROME_DRIVER = r " ./browser_drivers/chromedriver " driver = webdriver.Chrome( executable_path =CHROME_DRIVER) driver.implicitly_wait( 10 ) driver.get( "https://www.spicejet.com" ) time.sleep( 4 ) # Initialize ActionChains Object actionchains = ActionChains(driver) login_element = driver.find_element(By.ID, "ctl00_HyperLinkLogin" ) club_members_element = driver.find_element_by_xpath( '//a[text()="SpiceClub
This post will be quick beginner's tutorial for Selenium using Python binding. First step is to install "python-selenium" and get the required browser driver's. The official link has all the details required to install selenium package for python and links for getting drivers for different browsers. First step is to import the webdriver class from selenium and set the path for the browser driver. from selenium import webdriver CHROME_DRIVER = r "./browser_drivers/chromedriver" SAFARI_DRIVER = r "/usr/bin/safaridriver" In this tutorial, I am using both Chrome and Safari brower. If you are using Mac, you would need additional settings. Run the following command on Mac, if you get the not verified error :- xattr -d com.apple.quarantine ./browser_drivers/chromedriver Next, we will create the driver object to interact with the browser. Ths can be created by calling the appropritate browser class like Chrome, Firefox etc. Note : For Mac, safaridrive