如何实现Watir类(例如PageContainer)?
题
我正在用Watir编写一个示例测试,在那里我使用IE类浏览网站,发出查询等。 这非常有效。
我想继续使用 PageContainer 的方法我登陆的最后一页。 例如,在该页面上使用其HTML方法。
现在我是Ruby的新手,刚开始为Watir学习它。
我尝试在OpenQA上提出这个问题,但由于某些原因,Watir部分仅限于普通会员。
感谢您查看我的问题。
编辑:这是一个简单的例子
require "rubygems"
require "watir"
test_site = "http://wiki.openqa.org/"
browser = Watir::IE.new
browser.goto(test_site)
# now if I want to get the HTML source of this page, I can't use the IE class
# because it doesn't have a method which supports that
# the PageContainer class, does have a method that supports that
# I'll continue what I want to do in pseudo code
Store HTML source in text file
# I know how to write to a file, so that's not a problem;
# retrieving the HTML is the problem.
# more specifically, using another Watir class is the problem.
Close browser
# end
解决方案
目前,获取Watir问题答案的最佳位置是 Watir-General 电子邮件列表。
对于这个问题,看到更多代码会很高兴。正在测试的应用程序(AUT)是否打开了一个新的窗口/选项卡,您无法访问它,因此想要尝试使用PageContainer,还是只是导航到第二页?
如果是第一个,你想看一下#附上,如果是第二个,那么我建议你阅读快速入门教程。
在上面添加的代码后进行修改:
我认为您错过的是 Watir :: IE 包括Watir :: PageContainer 模块。因此,您可以致电browser.html
以获取您导航到的页面上显示的HTML。
其他提示
我同意。在我看来,browser.html
就是你想要的。
不隶属于 StackOverflow