`

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去操纵它们

    分享到:
    评论

    相关推荐

      python selenium 弹出框处理的实现

      总结,处理Python Selenium中的弹出框,我们需要根据弹出框的类型使用不同的策略。对于页面内弹出框,我们依赖元素定位;而对于浏览器级别的Windows弹出框,我们利用`switch_to.alert`方法来操作。理解这些基本概念...

      selenium---详细讲解

      这段代码首先点击包含Dojo下拉菜单的元素,然后等待弹出菜单的出现,最后选择其中的一个选项。这种精细的控制对于测试复杂的Dojo应用至关重要。 #### 总结 Selenium作为自动化Web测试领域的佼佼者,不仅能够处理...

      Selenium alert 弹窗处理的示例代码

      在网页自动化测试中,Selenium 是一个非常强大的工具,它能够模拟用户与页面的交互,包括处理各种弹出窗口。本文将深入探讨如何使用 Selenium 应对三种类型的弹窗:alert(警告信息)、confirm(确认信息)和 prompt...

      QTP学习与实践经验总结

      例如,我们可以编写一个自定义操作来处理弹出窗口,这样在多个测试场景中遇到相同窗口时,只需调用该操作即可。自定义操作可以通过VBS(Visual Basic Script)实现,充分利用其强大的编程能力。 系统参数设置是QTP...

      Python无头爬虫下载文件的实现

      为了让下载过程更加顺畅且不会弹出提示窗口,我们需要对下载行为进行配置: ```python prefs = {'profile.default_content_settings.popups': 0, 'download.default_directory': './filelist'} chrome_options.add_...

    Global site tag (gtag.js) - Google Analytics