2016-05-18 11 views
1

Milonicメニューの項目の選択を自動化しようとしています。私はこのようなコードを使用しています:Milonicメニュー:ポイントで要素をクリックできません。他の要素がクリックを受け取る

from selenium import webdriver 
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions 
from selenium.webdriver.common.by import By 

driver = webdriver.Firefox() 
example_menu = driver.find_element_by_id('m_example') 
example_menu.click() 
# Wait for the "Example Choice" choice to appear 
choice_present = expected_conditions.presence_of_element_located((By.LINK_TEXT, 'Example Choice')) 
WebDriverWait(driver, 5).until(choice_present) 
# Click on "Example Choice" 
example_choice = driver.find_element_by_link_text('Example Choice') 
example_choice.click() 

しかし、WebDriverExceptionは、このようなメッセージを発生します

Element is not clickable at point (236, 44). Other element would receive the click 

答えて

1

ソリューションは、メニュー項目の上にマウスを移動しますが、クリックするActionChainsを使用することですMilonicリンク:

from selenium import webdriver 
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions 
from selenium.webdriver.common.by import By 
from selenium.webdriver.common.action_chains import ActionChains 

driver = webdriver.Firefox() 
example_menu = driver.find_element_by_id('m_example') 
example_menu.click() 
# Wait for the "Example Choice" choice to appear 
choice_present = expected_conditions.presence_of_element_located((By.LINK_TEXT, 'Example Choice')) 
WebDriverWait(driver, 5).until(choice_present) 
# Use an action chain to move to the "Example Choice" but click on the 
# Milonic menu link 
example_choice = driver.find_element_by_link_text('Example Choice') 
mmlink1 = driver.find_element_by_id('mmlink1') 
action_chain = ActionChains(driver) 
action_chain.move_to_element(example_choice) 
action_chain.click(mmlink1) 
action_chain.perform() 
関連する問題