Category: python

Hover using Selenium webdriver’s ActionChains

I was recently trying to figure out how to perform a hover event using Selenium’s webdriver. The team I had previously worked on wrote a nifty function using execute_script invoking jQuery. It looked something like this:

This didn’t always work the way I expected so I did some research and came across webdriver’s ActionChains. From Selenium-Python’s ReadTheDocs:

ActionChains are a way to automate low level interactions such as mouse movements, mouse button actions, key press, and context menu interactions. This is useful for doing more complex actions like hover over and drag and drop.

I whipped open my terminal, fired up webdriver and headed over to the trusty the-internet to give it a whirl.

pip is a package manager for Python. It makes it easy to install and upgrade Python packages using the command line. Installing a Python package using pip is as easy as opening the command line and typing:

pip install -U requests

“requests” is the package you want to install

“install” tells pip you want to install a package. If you want to uninstall a package simply type “uninstall”.

The “-U” flag tells pip that if the package is already installed, then upgrade it.