我正在用selenium webdriver編寫一個python腳本來從網站獲取一些數據,並且 我試圖點擊this網頁中的下一個按鈕。當按鈕被定義爲:Python Selenium with Phantomjs - 點擊失敗:ReferenceError:找不到變量
<a id="ctl00_FullRegion_npsGridView_lnkNext" class="nextCol" href="javascript:__doPostBack('ctl00$FullRegion$npsGridView$lnkNext','')">Next</a>
王氏下面的代碼在python
URL='http://www.nordpoolspot.com/Market-data1/Elspot/Area-Prices/ALL1/Hourly/'
nextId="ctl00_FullRegion_npsGridView_lnkNext"
browser=webdriver.PhantomJS('./phantomjs')
browser.get(URL)
nextBtn=browser.find_element_by_id(nextId)
time.sleep(5)
nextBtn.click()
使用Firefox或Chrome的webdriver時,這工作得很好,但與Phantomjs我碰到下面的錯誤。
selenium.common.exceptions.WebDriverException: Message: u'Error Message => \'Click
failed: ReferenceError: Can\'t find variable: __doPostBack\'\n caused by Request
這個錯誤在谷歌搜索了很多大作,但havnt真正發現使用phantomjs時的方式解決它。
從這[SO問題](http://stackoverflow.com/questions/16863773/python-selenium-javascript-link-click-fails-執行)。嘗試調用「提交」方法,讓我知道? – Rohit
已經試過了。謝謝。提交沒有給出錯誤,但留下整個html表空白。 –