steel
steel

Reputation: 12520

View HTML of plain capybara element without using the driver

Please note the difference between my question and others like this one is that I am looking for a way to do this without using driver methods.

Is there a way to view all the HTML of a given Capybara Element without driver support?

Currently, a plain Capybara element allows you to access the attributes, if you know about them:

# <span class="one" id="two" data="three">
el = find(".klass")
el['class'] #=> "one"
el['id'] #=> "two"

It seems like surely there should be a way to just view the entire set of attributes, but I can't find a way without driver support. Is there a way to get something like this?

el.html #=> <span class=\"one\" id=\"two\" data=\"three\">

Upvotes: 0

Views: 88

Answers (1)

Brad Werth
Brad Werth

Reputation: 17647

No, there is not. Here are the methods you get. The closest you get is the native method, which you do not wish to use. You can see how it is done by drivers by looking at their code - you need the driver. You can verify this yourself by running my_cabybara_element.methods.sort, there just isn't anything there for this.

Upvotes: 1

Related Questions