使用watir检查标记类? [英] Check tag classes with watir?

查看:110
本文介绍了使用watir检查标记类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个div,根据表单是否正确提交而更改。

我想知道是否可以检查类的特定元素?

I have a div that changes based on if the form was submitted correctly or not.
I wanted to know if it's possible to check a specific element for a class or not?

<div id="myerrortest" class="input text"></div>

如果输入不正确,请添加错误类。

If the input isn't correct add the error class.

<div id="myerrortest" class="input text error"></div>


推荐答案

尝试:

browser.div(:id => "myerrortest").class_name

详情:

http://watir.github.com/watir-webdriver/doc/Watir/HTMLElement.html#class_name-instance_method

另一个替代方法是只查看你期望的类的div是否存在

Another alternative would be to just see if the div with class you expect exists or not

browser.div((:id => "myerrortest", :class => 'input text').exists?

如果使用rSpec类型匹配器,它将是

If using rSpec type matchers it would be

browser.div((:id => "myerrortest", :class => 'input text').should exist

这篇关于使用watir检查标记类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆