Is there an alternative to watir::ie.attach for watir-webdriver since attach is
- 博客分类:
- watir-webdriver
- watir
Question:
I have a website which is only rendered in Webkit enabled browser (Google Chrome, Safari). I am using Google Chrome since I am on Windows 7.
I am using Watir-WebDriver to automate the same.
Issue: When I click on a button on the browser window, is launches another window and post click content is rendered in the new browser window. I need a way to be able to Identify this new browser window, in-order to be able to proceed with my testing. I have been reading on various forums, but not getting any certain answer/solution.
Q: Is there an alternative to watir::ie.attach for watir-webdriver since attach is not supported on Watir-Webdriver
Sample code:
require "rubygems"
require "watir-webdriver"
require "selenium-webdriver"
b = Watir::Browser.new(:chrome)
website = "http://xyz.com"
#a new browser is launched and the website is opened
b.goto(website)
#this opens a new browser window
b.link(:xpath,"/html/body/div/ul/li/a").click
#there is a button called "MAP" on the new browser window
b.link(:id,"btn_MAP")
#this gives an error, unknown link
Answers:
A1:
"window" method is the alternative for ie.attach. Webdriver can handle the window opened by itself with window method.
b.link(:href,/server\/getPage/).click
b.window(:url,/server\/getPage/i).use do
b.link(:id,"btn_MAP").click
end
you can handle popped up windows in the window method block. If you want to keep handling popped up window, use it without block, like window(:url,/foobar/).use
see also: http://groups.google.com/group/watir-general/browse_thread/thread/232df221602d4cfb
A2: Thanks a lot for all your help it lead me to use something like the following and it worked!
b.link(:xpath,"/html/body/div/ul/li/a").click
c = b.window(:url,"http:\/\/server\/getPage\/67\/1354")
c.use
b.link(:id,"btn_MAP").click
发表评论
-
Get values from a select list using xpath [closed]
2012-04-04 16:50 0http://stackoverflow.com/que ... -
How do I build Watir tests for websites?
2012-04-04 16:14 0http://stackoverflow.com/que ... -
“TypeError: can't convert String into Integer” when trying to CTRL+click or SHIF
2012-04-04 15:33 0http://stackoverflow.com/que ... -
Using Watir, how can I select a radio control using both name and value?
2012-04-04 15:23 0q http://stackoverflow.com/q ... -
Selecting multiple options in select list with shift
2012-04-04 15:19 0Q http://stackoverflow.com/ques ... -
Drag-and-Drop in Watir
2012-04-04 15:15 0http://www.cheezyworld.com/2010 ... -
How to test onclick in this object without id
2012-04-04 15:13 0http://stackoverflow.com/que ... -
Browser Certificates
2012-04-04 15:01 0http://watirwebdriver.com/b ... -
selected_options returns blank from iframe
2012-04-04 14:48 0link http://stackoverflow.com/q ... -
How to handle tinyMCE when automating with watir-webdriver?
2012-04-04 14:28 0I'm evaluating Watir-webdr ... -
Browser url not returning new url
2012-04-01 17:55 0Qhttp://stackoverflow.com/quest ... -
Can not drive Opera with watir-webdriver on Windows XP
2012-04-01 17:53 0Qhttp://stackoverflow.com/quest ... -
why must I sleep or wait using watir-webdriver and firefox?
2012-04-01 17:50 0Qhttp://stackoverflow.com/quest ... -
Firefox 4 with watir webdriver: Need help using helperApps.neverAsk to save CSV
2012-04-01 17:39 0Q http://stackoverflow.com/q ... -
Watir Webdriver counting number of items in a UL list
2012-04-01 17:22 0Q http://stackoverflow.co ... -
finding the direct child of a tag in watir
2012-04-01 17:13 0Qhttp://stackoverflow.com/quest ... -
How to determine browser type (IE, FF, Chrome, etc.)
2012-04-01 16:59 0Q http://stackoverflow.com/que ... -
Wait methods for watir-webdriver unsuccessful with JS/AJAX and new page load (Er
2012-04-01 16:19 0http://stackoverflow.com/questi ... -
How to send text to a CKEditor WYSIWYG editor box using Watir-WebDriver
2012-04-01 16:14 0Q http://stackoverflow.com/ques ... -
How can I get Browser.text.include? to be case insensitive?
2012-04-01 15:57 0Q:http://stackoverflow.com/ques ...
相关推荐
### WATIR-WEBDRIVER自动化学习指导 #### 一、简介 WATIR-WEBDRIVER是一款基于Ruby语言的Web自动化测试框架,它能够帮助开发者和测试工程师编写高效的自动化测试脚本。WATIR(Web Application Testing In Ruby)与...
在Linux环境下进行自动化测试时,Watir-Webdriver是一个非常有用的工具。它是一个Ruby库,允许用户使用Ruby语言控制浏览器,进行网页元素的交互和测试。Watir是“Web Application Testing in Ruby”的缩写,而...
对于"watir安装所需要的gem包",主要涉及的Gem包有`watir-webdriver`和`selenium-webdriver`。`watir-webdriver`是Watir的一个版本,它使用Selenium WebDriver作为后端,与浏览器进行通信。而`selenium-webdriver`则...
开源自动化测试工具组合:Ruby+Watir安装 安装准备: 1. 工具安装包准备: Ruby官方下载地址:http://www.ruby-lang.org/zh_cn/downloads/,稳定版本Ruby 1.8.6 Watir下载地址:...
开源自动化测试工具组合:Ruby+Watir安装 安装准备: 1. 工具安装包准备: Ruby官方下载地址:http://www.ruby-lang.org/zh_cn/downloads/,稳定版本Ruby 1.8.6 Watir下载地址:...
Ruby 2.00、Selenium WebDriver 和 Watir WebDriver 是自动化测试领域中广泛使用的工具,尤其在Web应用程序的测试中。下面将详细讲解这三个概念及其相互关系。 Ruby 2.00 是Ruby编程语言的一个版本,发布于2013年,...
ruby2.0.0+selenium-webdriver+watir-webdriver+rails离线备份,设置环境变量后可使用(未测试)
2.本地安装watir-1.4.1.gem,执行gem install watir-1.4.1.gem -l 3.本地安装rubygems-update-1.3.4.gem,执行 gem install rubygems-update-1.3.4.gem 4.更新rubygems,执行update_rubygems (这一步先忽略,有影响...
expect(@browser.title).to include('Watir - Ruby Gem for Web Automation') end end ``` 这个例子展示了如何使用RSpec编写一个测试用例,其中包含了测试前后的浏览器初始化和关闭,以及预期结果的验证。 ### *...
browser = Watir::Browser.new :chrome, driver: Selenium::WebDriver.for(:chrome) ``` #### 六、最佳实践 - **保持代码整洁**:遵循良好的编程习惯,如使用有意义的变量名、注释等。 - **测试数据分离**:将...
**标题:“Watir-Bonus-1.5.1.1230.zip”** 这个压缩包包含的是Watir的扩展版本1.5.1的1230次更新,名为“Bonus”。Watir(Web Application Testing in Ruby)是一个开源的Ruby库,用于自动化浏览器操作,它使得...
Successfully installed watir-1.6.5 ``` #### 其他注意事项 - 如果安装过程中出现文档生成错误,如找不到 README 文件等,可以忽略这些错误继续进行。 - 确保安装了正确的 `activesupport` 版本,避免使用较新...
### Ruby Watir 教程详解 #### 一、Ruby Watir 概述 **Ruby Watir** 是一种用于网页自动化测试的工具库,它能够模拟用户在浏览器中的操作行为,如点击按钮、填写表单等,非常适合进行功能测试、回归测试和系统测试...
ChromeDriver 是一款以 Google Chrome 为环境测试网站的工具,现已实现对开源的 WebDriver 通路协议的支持,因此可以轻松与现有的 WebDriver 测试工具相整合。不熟悉 WebDriver 的用户可以参考 2009 年的项目发布...
压缩包中包含目前2013/01/19最新的安装文件,有rubyinstaller-1.9.2-p136、DevKit-tdm-32-4.5.1-20101214-1400-sfx、rubygems-1.8.24、watir-4.0.2、watir-webdriver-0.6.2等文件,并附上简略安装说明。
4. Watir+Cucumber示例项目:https://github.com/watir/watir-webdriver-example 通过实践和不断学习,你将能够熟练掌握Watir,编写出高效且易于维护的自动化测试脚本,提升你的软件测试能力。
安装将此代码添加到您的Gemfile中: group :test do gem "watir-rails"end用法就像您在请求/集成测试中一如既往地使用Watir: browser = Watir :: Browser . newbrowser . goto home_pathbrowser . text_field ( ...