简体   繁体   中英

Selenium Webdriver(Javascript) : Mouse events in selenium webdriver (mousover, click, keyup)

I am trying to implement selenium testing for mouse events on the dynamically generated elements.

I am trying to implement "mouseover" event for the element and later click on some icons on it. But, I am not able to do so.

Can, Anyone suggest or help me in resolving the issue on how to test the "mouseover" events

I am using Selenium-Webdriver with Javascript

Thanks in Advance.

In python I could do something like this (google.de as example):

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains

Url = 'https://www.google.de'
driver = webdriver.Chrome(executable_path=r'C:\Program Files\chromewebdriver\chromedriver.exe')
driver.maximize_window()

driver.get(Url)
element_to_hover_over = driver.find_element_by_xpath("/html/body/div/div[3]/div[2]/div/div/div[2]/div[1]/div[1]/a")
driver.implicitly_wait(20)

hover = ActionChains(driver).move_to_element(element_to_hover_over)
hover.perform()
element_to_hover_over.click()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM