一、处理模态窗口:showModalDialog

由于弹出模态窗口后,就无法定位到当前窗口的元素和模态窗口的元素,需要添加js解决

模态窗口动作类似下面语句:

  1. <input id="ctl00_CPH_TopAddButton" class="LongOrangeButtonStyle" type="button" value="Add Single Location" onclick="javascript:window.showModalDialog('EditLocation.aspx?EditOrAdd=Add',window,'dialogWidth:450px;dialogHeight:600px;status:no; directories:yes;scrollbars:no;Resizable=no;status:no');RefreshLocation();" name="ctl00$CPH$TopAddButton">

此时,在生成模态窗口前, 先执行语句:

storeEval  if(selenium.browserbot.getCurrentWindow().showModalDialog){selenium.browserbot.getCurrentWindow().showModalDialog = function(sURL,vArguments,sFeatures){selenium.browserbot.getCurrentWindow().open(sURL, 'modal', sFeatures);};}  xx

再点击

click 

id=ctl00_CPH_TopAddButton

   

则会以新页面形式弹出,就不会定位不到元素

操作完新页面后,执行下面2个语句,回到主窗口。

close    
selectWindow null  

二、处理confirm/alert/prompts弹出窗口

处理方式如下:

相应示例代码如下:

  1. <!DOCTYPE HTML>
  2. <html lang="zh-cn">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  5. <title>主窗口</title>
  6. <script type="text/javascript">
  7. function output(resultText){
  8. document.getElementById('output').childNodes[0].nodeValue=resultText;
  9. }
  10.  
  11. function show_confirm(){
  12. var confirmation=confirm("Choose an option.");
  13. if (confirmation==true){
  14. output("Confirmed.");
  15. }
  16. else{
  17. output("Rejected!");
  18. }
  19. }
  20.  
  21. function show_alert(){
  22. alert("I'm blocking!");
  23. output("Alert is gone.");
  24. }
  25. function show_prompt(){
  26. var response = prompt("What's the best web QA tool?","Selenium");
  27. output(response);
  28. }
  29. </script>
  30. </head>
  31. <body>
  32.  
  33. <input type="button" id="btnConfirm" onclick="show_confirm()" value="Show confirm box" /></br>
  34. <input type="button" id="btnAlert" onclick="show_alert()" value="Show alert" /></br>
  35. <input type="button" id="btnPrompt" onclick="show_prompt()" value="Show prompt" /> </br>
  36. <br />
  37. <span id="output">
  38. </span>
  39. </body>
  40. </html>

selenium IDE处理各种窗口问题解决方法的更多相关文章

  1. selenium2.0 处理各种窗口问题解决方法

    selenium2.0处理muti-Windows . Frames .Popup Dialogs selenium2.0处理多窗口,弹窗等,只需要调用WebDriver 嵌套类:TargetLoca ...

  2. Selenium IDE录制脚本时弹出窗口的完美处理

    很多朋友录制脚本时新打开弹出窗口后无法定位元素,我也遇到同样的问题,国内没有什么好的资料,于是就阅读英文,不断尝试,感觉那个selectWindow(title)什么就是个坑,我用这种方法成功处理后得 ...

  3. java绘图原理------在窗口界面(或面板上)画出一张或多张图片问题解决方法

    /** *@author blovedr * 功能: java绘图原理------在窗口界面(或面板上)画出一张或多张图片问题解决方法 * 日期: 2018年4月28日     16:20 * 注释: ...

  4. Python+selenium自动化测试中Windows窗口跳转方法

    Python+selenium自动化测试中Windows窗口跳转方法 #第一种方法 #获得当前窗口 nowhandle=driver.current_window_handle #打开弹窗 drive ...

  5. selenium IDE中log的保存与查看方法

    下载selenium IDE的log保存插件为File Logging(selenium IDE),下载安装方式如下: (1)打开firefox浏览器----点击右上角----附加组件---插件--- ...

  6. Selenium IDE和Selenium RC的安装

    1       安装FireBug和FirePath 1.在火狐浏览器中,点击”添加附件”按钮,弹出”附加组件管理器”页面 2.在弹出页面中,输入“fireBug”,点击“搜索”按钮,弹出fireBu ...

  7. 测试那些事儿—selenium IDE 自动化测试

    浏览器 Firefox Setup 35.0.1 安装完成后设置菜单栏 关闭浏览器自动更新 插件配置(必备武器) FireBug Firebug是firefox下的一个扩展,能够调试所有网站语言,如H ...

  8. Selenium IDE 3.6 命令Command详解

    学以致用,个人觉得要学老外的东西,最好的方法就是自己翻译一遍.因此准备把SIDE官网的一些文档,按工作所需做些翻译整理.本文是命令这一块的提纲,未全部完成,占坑中. Selenium IDE中的命令其 ...

  9. 自动化测试模型 Selenium IDE Selenium Gird2

    1.线性测试 每个测试脚本相对独立,且不产生其他依赖与调用,其实就是单纯的来模拟用户完整的 操作场景.前一篇所写的测试脚本就属于线性测试. 优点:每个脚本完整且独立 缺点:测试用例的开发与维护成本高 ...

随机推荐

  1. 改进的SMO算法

    S. S. Keerthi等人在Improvements to Platt's SMO Algorithm for SVM Classifier Design一文中提出了对SMO算法的改进,纵观SMO ...

  2. poj 1459 Power Network【建立超级源点,超级汇点】

    Power Network Time Limit: 2000MS   Memory Limit: 32768K Total Submissions: 25514   Accepted: 13287 D ...

  3. Linux为Tomecat指定JDK

    在搭建Jenkin+Sonar集成时,由于系统环境配置了jdk1.7,但是jenkins在安装sonar的插件时,需要jdk1.8.,所以需要在Tomcat指定jdk1.8. (1)暂停Tomcat ...

  4. tomcat热部署,更改java类不用重新加载context

    修改类后,tomcat热部署会重新加载整个项目的context,影响开发效率.网上查的大多数是将server的modules标签中Auto Reload项改为Disabled,但是没有效果. 使用以下 ...

  5. spring问题org.springframework.beans.factory.CannotLoadBeanClassException

    1.看jdk是否配置正确 2.把MyEclipse里面的那个classes删除让他重新编译就没什么问题了,只要配置是对的 3.重新clean project

  6. PHP 函数:intval()

    intval   变量转成整数类型. 语法: int intval(mixed var, int [base]); 返回值: 整数 函数种类: PHP 系统功能 内容说明:本函数可将变量转成整数类型. ...

  7. WordPress公布新文章Email通知注冊用户

    非常多WordPress博客都开放了用户注冊的功能,用户能够參与到博客的内容建设其中来.也就是一个博客由多个用户来写.如今有这种需求,怎样实如今某一个用户发表文章后.其它用户都能收到Email通知?以 ...

  8. centos nginx install openssl

    1.查看是否已经安装 ssl 组件 [root@localhost wwwlogs]# cd /usr/local/nginx/sbin/ [root@localhost sbin]# ./nginx ...

  9. SpringMVC + ehcache( ehcache-spring-annotations)基于注解的服务器端数据缓存

    背景 声明,如果你不关心java缓存解决方案的全貌,只是急着解决问题,请略过背景部分. 在互联网应用中,由于并发量比传统的企业级应用会高出很多,所以处理大并发的问题就显得尤为重要.在硬件资源一定的情况 ...

  10. [React] React Fundamentals: Mixins

    Mixins will allow you to apply behaviors to multiple React components. Components are the best way t ...