0
實際上是兩個問題:硒web_driver的Javascript問題關閉瀏覽器窗口
第一個:反正是有開始在特定的URL瀏覽器(而不是約:空白)(我想擁有的歷史長度在該網址上開始0時)
第二個: 我相信這是有關上述問題的
在網頁上我有以下幾點:
<script type="text/javascript">
function backAway(){
if (navigator.appName == 'Microsoft Internet Explorer'){
// under ie
i = 0;
} else {
//firefox, chrome, etc..
i = 1;
}
if (history.length>i)
{
// there appear to be items in the history property
// this seems to happen with Firefox
// If refferer exists, then do a back
if (document.refferer){
history.back();
} else {
window.close();
}
} else {
window.close();
}
return false;
}
</script>
<a href="" id="declineButton" title="Cancel" class="canc" onclick="backAway(); return false;">Cancel</a>
蟒蛇硒的東西在這裏:
driver = webdriver.Firefox()
driver.get(urlOAuth)
declineButtons = driver.find_elements_by_id('declineButton'])
declineButtons[0].click()
它成功地找到了declineButton,但點擊似乎沒有任何效果。 當不使用硒時,頁面顯示正常工作。
有什麼想法?建議?有問題嗎?