2017-03-24 77 views
0

我在寫一個硒測試用例來自動化surveymonkey試圖用selenium自動化surveymonkey

import time 
from selenium import webdriver 
from selenium.webdriver.common.keys import Keys 
from selenium.webdriver.chrome.options import Options 
chrome_options = webdriver.ChromeOptions() 
chrome_options.add_argument("-incognito --no-sandbox") 
driver = webdriver.Chrome(executable_path='/usr/lib64/chromium/chromedriver', chrome_options=chrome_options) 
driver.get('https://www.surveymonkey.com/r/WXNXWVB') 
time.sleep(3) 
vote_check = driver.find_element_by_id('96247410_725897453') 
vote_check.click() 
time.sleep(3) 
nxt_btn = driver.find_element_by_name('Done') 
nxt_btn.click() 
driver.quit() 

我也得到了流動錯誤:

selenium.common.exceptions.WebDriverException: Message: unknown error: Element <input id="96247410_725897453" name="96247410" type="radio" class="radio-button-input" value="725897453"> is not clickable at point (850, 203). Other element would receive the click: <span class="radio-button-display ">...</span> 

我在做什麼錯?

+0

'vote_check = driver.find_element_by_id('96247410_725897453')'這不會工作。 Try try Using: 'vote_check = driver.find_element_by_xpath(「.//*[@ id ='question-field-96247410']/fieldset/div/div/div [1]/div/label/span [1] 「)' –

+0

對於選項1: vote_check = driver.find_element_by_xpath(」 //標籤[@爲= '96247410_725897453'] 「) 對於選項2: vote_check = driver.find_element_by_xpath(」 //標籤[@爲=」 96247410_725897454']「) –

+0

這部分工作很好,我明白你在做什麼? 現在我怎麼也點擊完成按鈕? – Bogdan

回答

0

請查找下面可行代碼:

對於選項1:

vote_check = driver.find_element_by_xpath("//label[@for='96247410_7258974‌​53']") 

選項2:

vote_check = driver.find_element_by_xpath("//label[@for='96247410_7258974‌​54']") 

完成:

vote_check = driver.find_element_by_xpath("//button[contains(text(), ' Done')]") 

試着在你結束並讓我知道。

相關問題