小编Fab*_*e31的帖子

如何避免页面对象被弃用的复选框

我从一年开始使用黄瓜,而且几周之后我就在它中添加了page-object-gem.当我执行测试时,我收到消息:

DEPRECATION WARNING
您正在commentPage.rb中调用一个名为checkbox的方法:23:在`delete in delete_comment'中.
此方法在页面对象中不存在,因此它将传递给驱动程序.
此功能将在不久的将来删除.
请更改您的代码以调用正确的页面对象方法.

(我对其他案例也有同样的看法,但这个"琐碎"的例子应该更容易解释)

我试图避免这种情况,但这看起来很复杂.

对于测试,我正在检查一个页面,其中有一个表格.每行显示一行,我需要检查特定行的复选框.

我在pageObject中的代码:

table(:comment_list, :class => 'comments')
button(:delete, :text => "Delete")

def delete_comment (text)
  self.comment_list_element.each do |row|
    if row.text.include? "#{text}"
      row.checkbox.set
      self.delete
      return true
    end
  end
  false
end
Run Code Online (Sandbox Code Playgroud)

我是否需要对我的桌子进行预处理以在测试期间使用它?

watir watir-webdriver pageobjects page-object-gem

2
推荐指数
1
解决办法
1220
查看次数

如何在PageObject中使用css获取元素

在我添加测试的项目中,我有一些复杂的元素“获取”。
我的 textarea 的 html :

<div class="quote">        
 <div class="clearfix">          
  <div class="icon"></div>            
   <div class="text">
    <span class="yui3-widget yui3-inputwidget yui3-textareawidget yui3-textareawidget-focused" style="">
     <span class="yui3-textareawidget-content">
      <textarea name="" placeholder=""></textarea>
     </span>
    </span>
   </div>        
   <div class="author">
    (...) other text_field 
   </div>
  </div>        
 </div>    
</div>
Run Code Online (Sandbox Code Playgroud)

目前,我使用这一行来设置值

@browser.element(:css => ".quote textarea").send_keys "test"
Run Code Online (Sandbox Code Playgroud)

在 PageObject 中,我应该声明元素并使用它:

# declaration at the top
element(:quote_text, :css => ".quote textarea") 
# use it where I need
self.quote_text = "text"
Run Code Online (Sandbox Code Playgroud)

但是当我使用时出现此错误:

undefined method `quote_text=' for #<PublishPage:0x33843c0> (NoMethodError)
Run Code Online (Sandbox Code Playgroud)

我哪里错了?

watir page-object-gem

2
推荐指数
1
解决办法
6284
查看次数