`

Selenium应对弹出窗口总结

阅读更多
弹出窗口有如下几种类型

  • Https页面弹出窗口
  • 在IE浏览器下,htttps页面会出现Security Alert警告框,以及"Security Information"信息框,在IE中,能通过修改IE设置去屏蔽这两个窗口.
    如果是Firefox,则可以通过定制Firefox Profile

    IE下设置如下:
    Security Alert:
    Step1:View Certificate then install it.
    Step2: Tool > Internet Options > Advanced, unselect security-> Warn about invalid site certificates 和 Check for publisher's certificate revocation.

    Security information:
    Tools > Internet Options > Custom Level, select Display mixed content

  • 通过window.open()生成的新窗口
  • 通过以下方法操作:
    selenium.waitForPopUp(windowname, timeout); 
    selenium.selectWindow(popupWindowIdentifier);
    //回到主窗口使用 'null' 
    selenium.selectWindow(null); 
    

    popupwindowIdentifier 是一个窗口标识符,可以是窗口 ID、窗口名称, 印象中windowname也不一定指的是name,或许也可以是ID或者title

  • 警告/确认/提示框
  • 是指用javascript的window.alert(), window.prompt(), window.comfirmation()函数生成的提示框.Selenium提供了getAlert(), getPrompt(),getConfirmation()方法可以处理

  • 上传下载弹出框
  • selenium不能直接处理这些对话框,因为不能通过Javascript去操纵它们

    分享到:
    评论

    相关推荐

    Global site tag (gtag.js) - Google Analytics