Mo.
Mo.

Reputation: 42523

how to Clear or replace contents of input field using selenium?

How can i clear the contents of an input field using ruby selenium?

i.e when page loads up there are values in the input filed but i want to replace them with new ones.

thank you

Upvotes: 2

Views: 9122

Answers (2)

Nafeez Quraishi
Nafeez Quraishi

Reputation: 6168

This is how i cleared and replaced with new text in my Ruby based web portal test

@driver.find_element(:xpath, "//input[@name='ip-address']").clear
@driver.find_element(:xpath, "//input[@name='ip-address']").send_keys(new_ip_address)

Upvotes: 1

Hannibal
Hannibal

Reputation: 1127

Come on guys... You can't be serious...

With selenium to clear an input field do this: selenium.type("") in ruby too.

And backspacing as many times as there are letters... Come on.. you don't do stuff like that.

Or in Ruby syntax: @browser.type "idofthefield", ""

Upvotes: 6

Related Questions