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

在watir中使用“@current_page”验证webelement

  •  -1
  • paul  · 技术社区  · 10 年前

    第1步和第2步让我回到“登陆页面”。我想使用 @current_page . 这是“LandingPage.rb”中定义的元素。

    我试过了,但没有运气。缺少什么?

    Step1
    Step2
    
    1. fail if not @current_page.(on(LandingPage.cart_box.present?))
    2. fail if not @current_page.(on(LandingPage.cart_box)).present?
    3. fail if not @current_page.(on(LandingPage.cart_box_element)).present?
    
    1 回复  |  直到 10 年前
        1
  •  0
  •   Justin Ko    10 年前

    假设 @current_page 已设置为 Step1 Step2 ,它将是 LandingPage 。您不应该拨打 on 方法

    根据您的目标,您可以执行以下任一操作:

    @current_page.cart_box?
    

    @current_page.cart_box_element.visible?
    

    注意,如果您希望检查未通过测试,则需要在测试框架的断言库中使用结果。