2

===============셀레늄은 Firefox에서 작동하지 않는 요소로 마우스 커서를 옮깁니다.

OS : Win7에

셀레늄 : 2.33.0

파이어 폭스 : 22.0

파이썬 : 2.7.4

=================== =============

o 메소드 "move_to_element"로 마우스 커서를 "input"요소로 이동 시키지만 할 수는 없습니다.

누구에게이 문제가 있습니까?

================================

#!/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() 

과제를 해결한다. move_to_element() 메서드는 실제 마우스 커서를 객체로 이동해야한다고 생각했습니다. 그러나 셀레늄은 실제 마우스 커서를 움직이지 않고 마우스를 움직입니다. 감사.

+0

작동 나던 방법 : 여기

은 예입니다? –

+0

감사! 그것은 내 잘못이야. 마우스 커서를 움직여야한다고 생각했습니다. 이제 괜찮아. :) –

답변

6

코드를 사용해 보았습니다. 무슨 뜻입니까? 무슨 일이 일어날 것으로 예상됩니까?

Baidu의 입력에 마우스를 가져 가면 시각적 인 효과가 없습니다. Selenium은 실제 마우스를 움직이지 않고 요소로 이동하므로 실제 마우스 커서의 위치가 변경되지 않습니다.

move_to_element을 정말로 테스트하려면 호버 효과가있는 것으로 테스트하여 시각적으로 볼 수 있습니다.

#!/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://stackoverflow.com/tags") 


tags = firefox.find_elements_by_css_selector("#tags-browser .tag-cell .post-tag") 

action = webdriver.ActionChains(firefox) 
action.move_to_element(tags[0]) 
action.perform() 
+0

고마워요! 그것은 내 잘못이야. 마우스 커서를 움직여야한다고 생각했습니다. 이제 괜찮아. :) –

+0

OK, 다시 한 번 감사드립니다! :) –

관련 문제