Check tag classes with watir?

前端 未结 2 1415
自闭症患者
自闭症患者 2021-01-19 03:35

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?

2条回答
  •  孤城傲影
    2021-01-19 03:55

    Try this:

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

    More information:

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

    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?
    

    If using rSpec type matchers it would be

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

提交回复
热议问题