Watir examples

简介: ExamplesAll examples are designed to work on the live Watir demo form: http://bit.ly/watir-example.Loading RubyGemsIf you’re a first time Ruby user, y...

Examples
All examples are designed to work on the live Watir demo form: http://bit.ly/watir-example.

Loading RubyGems
If you’re a first time Ruby user, you need to understand how to load Ruby gems such as Watir. You can require it via the -rubygems command line option or by using the RUBYOPT environment variable. You can also require it manually in your script:
require 'rubygems'


For more information see here.

Including Watir gem to drive Internet Explorer on Windows
require 'watir'

Including Watir-WebDriver gem to drive Firefox/Chrome on Windows/Mac/Linux
require 'watir-webdriver'

Starting a new browser & and going to our site
browser = Watir::Browser.new
browser.goto 'http://bit.ly/watir-example'


Setting a text field
browser.text_field(:name => 'entry.0.single').set 'Watir'

Setting a multi-line text box
browser.text_field(:name => 'entry.1.single').set "I come here from Australia. \n The weather is great here."

Setting and clearing a radio button
browser.radio(:value => 'Watir').set
browser.radio(:value => 'Watir').clear


Setting and clearing check boxes
browser.checkbox(:value => 'Ruby').set
browser.checkbox(:value => 'Python').set
browser.checkbox(:value => 'Python').clear


Clicking a button
browser.button(:name => 'logon').click

Clearing, getting and selecting selection list values
browser.select_list(:name => 'entry.6.single').clear
puts browser.select_list(:name => 'entry.6.single').options
browser.select_list(:name => 'entry.6.single').select 'Chrome'


Clicking a button
browser.button(:name => 'submit').click

Checking for text in a page
puts browser.text.include? 'Your response has been recorded.'

Checking the title of a page
puts browser.title == 'Thanks!'


more info: http://watir.com/examples/


 
 

 

 

目录
相关文章
|
机器学习/深度学习 人工智能 索引
Numpy User Guide系列笔记1:NumPy Quickstart Tutorial笔记
本文是NumPy quickstart这一教程的简单学习笔记。我学习这一教程的目的在于回顾numpy基础知识,以辅助后期对机器学习、人工智能这类较复杂知识的更深一步学习。 本文基于自己学习这一教程时撰写的jupyter notebook文件、以更便于网页浏览的方式改编而成。jupyter notebook文件的代码基本上全部基于原教程撰写,文件已发布在GitHub上,链接为:all-notes-in-one/NumpyQuickStartTutorials.ipynb at main · PolarisRisingWar/all-notes-in-one。
|
Web App开发 人工智能 测试技术
书籍:Learn Web Development with Python - 2018.pdf
简介 使用最流行的Python Web框架(Django)进行Web编程的Python编程综合指南 主要特点 了解使用Python编程和构建Web应用程序的基础知识 使用Django从头开始构建Web应用程序 使用最新的Django框架创建真实的RESTful Web服务 图书说明 如果您想使用Django开发完整的Python Web应用程序,这个学习路径适合您。
|
机器人 Python 数据格式
Robot Framework's built-in tool:libdoc
Libdoc是Robot框架的内置工具之一,用于生成HTML和XML格式的测试库和资源文件的关键字文档,使用起来我感觉非常的灵活方便。 General Usage 语法使用 python -m robot.
1326 0
|
Web App开发 Ruby Python
|
Web App开发 机器人 测试技术
Robot Framework之RIDE 编辑器介绍
一、RIDE 编辑器 RF 是通过 RIDE 编辑器进行工作的,安装成功后,可以通过以下2种方式打开: 1.执行命令“[PythonDir]\Scripts\ride.py”,就可以打开 RIDE 编辑器([PythonDir]指的是你Python的安装路径) 2.还可以通过以下方式设置快捷键打开 1>在桌面右击鼠标,弹出的菜单选择 新建-快捷方式 ,然后在 请键入对象 的位置输入这一行命令,F:\Python27\pythonw.exe -c “from robotide import main; main()”。
2524 0