How To: Mouse Hover Over In Selenium (1 Min) Using Actionchains In Python

preview_player
Показать описание
In this tutorial, you'll learn how to perform mouse hover over in Selenium Using Actionchains in Python & PyTest.



Video Transcript:


On line 7, I'm using the find underscore element method by XPath to find the flyout menu. Next, I'm using the action chains to hover the flyout menu. Line 11, I'm clicking on the change country link then getting the inner HTML attribute from the drop-down.

Finally, on line 16, I'm asserting whether the country is equal equal to the United States or not. Now let's run this test to see what the execution looks like. As you can see the test passed.

To export the test results in an HTML format click on the export results button. There you have it. Make sure you like, subscribe, and turn on the notification bell.

Until next time.



def test_amazon_fly_out_menu(driver):

ActionChains(driver).move_to_element(flyout_menu).perform()

print("country:", country)
assert country == 'United States'

--

Video Transcript

--
Hi guys, this is Abhi from Gokce DB. In this video, you’re going to learn how to perform mouse hover over in Selenium using Actionchains.

Let’s start by looking at the past scenario on amazon dot com. I want to hover over the country Flyout menu then click on change country’s last region.

Next, I want to assert whether the default country is set to United States or not. Now, let’s look at the past directory structure.

Under amazon underscore tests I have a conftest dot py file which contains their driver fixture function. This function is responsible for initializing the Chrome web driver.

Next, let’s look at the past file. On line six, I’m using the driver dot get method to go to amazon dot com.

On line seven, I’m using the find underscore element method by XPATH to find the Flyout menu. Next, I’m using the ActionChains to hover over the Flyout menu.

Line eleven, I’m clicking on the change country link then getting the inner HTML attribute from the dropdown. Finally, on line sixteen, I’m asserting whether the country is equal equal to United States or not.

Now, let’s run this test to see how the execution looks like. As you can see the tests passed.

To export the tests results in an HTML format click on the Export Tests Results button. There you have it.

Make sure you like, subscribe, and turn on the notification bell. Until next time.
Рекомендации по теме
join shbcf.ru