================================
OS: Win7
Selenium: 2.33.0
Firefox: 22.0
Python: 2.7.4
================================
I want to move the mouse cursor to the element "input" with method "move_to_element", but can't do it.
Do anyone have this issue?
================================
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from selenium.webdriver.common.by import By
import selenium.webdriver as webdriver
import time
firefox = webdriver.Firefox()
firefox.get("http://www.baidu.com")
input = firefox.find_element_by_id("kw")
action = webdriver.ActionChains(firefox)
action.send_keys_to_element(input, "testvalue")
action.perform()
#This step (move mouse to "input" element) NOT work! :(
action = webdriver.ActionChains(firefox)
action.move_to_element(input)
action.perform()
time.sleep(3)
firefox.quit()
Problem solved. I thought move_to_element() method should move the real mouse cursor to the object. But selenium does the mouse hover without moving real mouse cursor. Thanks.
Tried your code. What you do mean doesn't work? What do you expect to happen?
There is no visual effect when you hover to Baidu's input. Selenium moves to the element without moving the real mouse, so you won't see the position change of the real mouse cursor.
If you really want to test
move_to_element
, please test against something that has hover effect, so you can visually see it.Here's an example: