Željko Filipin
Željko Filipin

Reputation: 57262

How to access element with custom attribute using Watir?

I have HTML that looks like this:

<input custom_attribute="so cool" type="text" />

I would like to enter text in it using Watir.

Upvotes: 4

Views: 4170

Answers (2)

boulder_ruby
boulder_ruby

Reputation: 39695

Filipin's answer did not work for my job with watir-webdriver.

I did, however, find a way to do the job with css selectors.

browser.element(:css, "input[custom_attribute='so cool']").send_keys("the coolest")

Upvotes: 7

Željko Filipin
Željko Filipin

Reputation: 57262

browser.text_field(:xpath , "//input[@custom_attribute='so cool']/").set("even more cool")

Sources:

Upvotes: 5

Related Questions