網頁中自動彈出的對話框要怎么定位呢?
如圖,打開這個網站后,自動彈出的登錄框,我想定位“賬號密碼登錄”,并點擊。代碼嘗試如下,但是失敗了
div = driver.find_element_by_class_name('link').find_element_by_id('switcher_plogin')
div.click()
錯誤信息如下:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"class name","selector":"link"}
?(Session info: chrome=60.0.3112.7)
?(Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 6.3.9600 x86_64)
2017-08-25
這個你需要切換到當前窗口后才能進行定位,switch_TO以后才行
2019-03-28
樓主后來解決的方法能說一下么
2018-06-15
樓主怎么解決的