Watir: How can I execute in a watir script a specific javascript function called
Question
In a Watir script, after I check checkboxes in a popup window, I'm trying to execute a javascript function to add objects selected to the parent window.
What works fine until now it is the check of the checkbox, but object is not added to the parent window and I get following error when I executed the watir script: in `method_missing': execScript (WIN32OLERuntimeError)
This was my approach - please let me know what other method I can use
ie.checkbox(:id => "check_asm0option0").set
ie.document.parentWindow.execScript("window.triggerOriginalChange(asm0option0, add);","JavaScript")
tr class="tr_option" rel="asm0option0"
td class="td_check"
input id="check_asm0option0" type="checkbox" value="4dbb118ddca3244e2800003d" rel="asm0option0" name="ignore"
/td
td class="td_li"
li value="0" rel="asm0option0" test /li
/td
/tr
if using .set doesn't result in your code working the way you'd expect, then examine the source and then try using .fireEvent to fire the event that should trigger the script that needs to execute.
In this case I'd try
ie.checkbox(:id => "check_asm0option0").fireEvent('onChange')
that approach is generally a bit more organic and easier than trying to invoke the script manually
发表评论
-
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 ...
相关推荐
- **Browser类**: 代表一个浏览器实例,如`browser = Watir::Browser.new :chrome` 创建一个新的Chrome浏览器。 - **Element类**: 表示HTML元素,如`button = browser.button(id: 'submit')` 获取id为'submit'的按钮...
使用Watir 本自述文件供有兴趣在Watir生态系统中利用私有API Watir代码编写Watir或gem的代码的人使用。 对于我们的用户,您需要的一切都在:示例,新闻,指南,其他资源,支持信息等。补丁/请求请求的过程分叉该项目...
Watir,全称为Web Application Testing in Ruby,是一个用于自动化浏览器操作的开源库,它使得编写测试脚本变得简单直观,可以模拟用户在浏览器中的各种交互行为。在Ruby编程语言环境中,Watir允许开发者通过编写...
browser = Watir::Browser.new ``` - 如果在不同电脑上操作 Watir 时遇到不同的问题(如需不需要 `require 'rubygems'`),这可能是由于环境设置的不同造成的。确保所有环境都一致地配置好 Ruby 和 RubyGems。 - ...
browser = Watir::Browser.new :chrome, driver: Selenium::WebDriver.for(:chrome) ``` #### 六、最佳实践 - **保持代码整洁**:遵循良好的编程习惯,如使用有意义的变量名、注释等。 - **测试数据分离**:将...
安装将此代码添加到您的Gemfile中: group :test do gem "watir-rails"end用法就像您在请求/集成测试中一如既往地使用Watir: browser = Watir :: Browser . newbrowser . goto home_pathbrowser . text_field ( ...
Ruby和Watir(Web Application Testing in Ruby)是一个强大的自动化测试框架,主要用于Web应用程序的测试。Ruby是一种面向对象的、动态的编程语言,以其简洁、优雅的语法和强大的元编程能力而受到开发者的喜爱。...
browser = Watir::Browser.start 'bit.ly/watir-webdriver-demo' text_field = browser.text_field(:id => 'entry_0') puts text_field.exists? # 判断文本框是否存在 text_field.set 'yourname' # 设置文本框的值 ...
通过设置`browser = Watir::Browser.new :chrome`,可以选择使用哪个浏览器进行测试。 6. **异常处理** 在编写测试脚本时,错误处理是必不可少的。Watir提供了如`begin-rescue-end`结构来捕获并处理可能的异常...
- **安装Gem**:例如安装Watir:`gem install watir` - **构建Gem包**:`gem build package.gemspec` - **列出已安装的Gems**:`gem list` - **检查已安装的Gem包**:`gem check` - **卸载Gem包**:`gem uninstall ...
2. 创建浏览器实例:`browser = Watir::Browser.new :chrome`(或其他浏览器) 3. 访问网页:`browser.goto 'http://example.com'` 4. 定位元素:`button = browser.button(text: 'Submit')` 5. 操作元素:`button....
Watir,全称为“Web Application Testing In Ruby”,是一款基于Ruby语言的开源Web自动化测试框架。它的设计目的是模拟人们在浏览器中的行为,如点击链接、填写表单和按下按钮,并能够检查预期的文本是否出现在页面...
开源自动化测试工具组合:Ruby+Watir安装 安装准备: 1. 工具安装包准备: Ruby官方下载地址:http://www.ruby-lang.org/zh_cn/downloads/,稳定版本Ruby 1.8.6 Watir下载地址:...
watir测试框架介绍 watir测试框架介绍 watir测试框架介绍
browser = Watir::Browser.new :chrome # 使用Chrome浏览器 browser.goto 'https://www.google.com' # 访问Google首页 search_field = browser.text_field(name: 'q') # 查找搜索框 search_field.set 'Ruby ...