0

其实有两个问题:

第一个:无论如何要在特定的 URL 上启动浏览器(而不是 about:blank)(我希望在该 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>

python selenium 的东西在这里:

 driver = webdriver.Firefox()
 driver.get(urlOAuth)
 declineButtons = driver.find_elements_by_id('declineButton'])
 declineButtons[0].click()

它成功地找到了decreaseButton,但点击似乎没有任何效果。不使用 selenium 时,该页面似乎可以正常工作。

有什么想法吗?建议?问题?

4

1 回答 1

0

这里没有数组的概念

使用语句 driver.findElement(By.id("declineButton")).click() 我相信这会起作用。

于 2014-04-04T10:15:36.587 回答