六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 39|回复: 0

Selenium应对弹出窗口总结

[复制链接]

升级  35.33%

27

主题

27

主题

27

主题

秀才

Rank: 2

积分
103
 楼主| 发表于 2013-1-29 09:32:18 | 显示全部楼层 |阅读模式
弹出窗口有如下几种类型

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去操纵它们
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表