代码之家  ›  专栏  ›  技术社区  ›  Dennis

如何实现Watir类(例如PageContainer)?

  •  2
  • Dennis  · 技术社区  · 17 年前

    那很好用。

    我想继续使用 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
    
    2 回复  |  直到 17 年前
        1
  •  1
  •   mandersn    17 年前

    目前,获得Watir问题答案的最佳地点是 Watir-General 电子邮件列表。

    如果是第一个,你想看看 #attach ,如果是第二个,那么我建议阅读 quick start tutorial

    在上面添加代码后进行编辑:

    我想你错过的是 Watir::IE module . 所以你可以打电话 browser.html 使html显示在您导航到的页面上。

        2
  •  1
  •   Bret Pettichord    17 年前

    browser.html 这就是你想要的。

    推荐文章