0
我使用selenuim webdriver以https方案獲取頁面。如果我使用chrome進入頁面,則會出現'隱私錯誤',並且響應爲空。 如果我使用webdriver獲取頁面,webdriver停留在它所在的最後一頁上。如何檢測webdriver沒有移動到新頁面?Selenuim webdriver因ssl錯誤而未通知而失敗
我想過檢查driver.current_url是否與我想要的url相同,但它不覺得是正確的解決方案。
代碼:
from selenium import webdriver
driver = webdriver.PhantomJS()
driver.get('http://doman.com/1.html') # this return 200 status and content
driver.get('https://domain2.com/2.html') # this return the privacy error
# so the driver is still at the first url
您是否嘗試過使用** ** webdriver.common.utils.is_url_connectable,看它捕獲錯誤不可連接? – Anzel 2015-03-03 09:47:49
@Anzel但這會做出另一個請求。它也會到硬編碼的本地服務器 – yossi 2015-03-03 10:36:59
這將是我想的限制,或者你可以簡單地包裝在嘗試/超時除外,看看是否加載新頁面。 – Anzel 2015-03-03 10:44:49