2016-07-09 11 views
1

私はPythonとSeleniumを使用してデータを収集しようとしていますが、最初のポップアップを過ぎても受け入れボタンをクリックして同意することはできません使用条件に!ウェブサイトはhereSelenium/python - 要素をクリックできません

です。私は 'Accept'リンク/ divにidがあり、find_element_by_xpathを使って試してみて、クリックしようとしたIDを選択しようとしましたが、うまくいきません。

また、ActionChainsを使用してボタンに移動してクリックすることも試みましたが、これも機能しません。返されるエラーは要素はポイントでクリックできません...

対処が難しいバックグラウンドで、いくつかのjquery/javascriptが実行されているようです!

ご協力いただければ幸いです。

答えて

2

トリックは、クリック可能ななっボタンに移動し、クリックしてボタンを「同意する」ため待つことです:

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


driver = webdriver.Firefox() 
driver.get("https://www.etfsecurities.com/institutional/uk/en-gb/products.aspx") 

wait = WebDriverWait(driver, 10) 
accept = wait.until(EC.element_to_be_clickable((By.ID, "btnPopupAccept"))) 

actions = ActionChains(driver) 
actions.move_to_element(accept).click().perform() 
+0

ありがとうございました!!完璧に働いた! – Matt

関連する問題