yoyo
yoyo

Reputation: 13

How to set value with selenium in RUBY program

I want to set like this

data-scene_cd="abc"

How can I do that with in program?

HTML is below one.

    <input id="bikeBox" type="text" class="input" data-scene_cd="" data-class_cd="" readonly="readonly">
    <input id="fourwdBox" type="text" class="fourwdBox input" data-fourwd_flg="0" readonly="readonly">

Upvotes: 0

Views: 1718

Answers (1)

Viet Pham
Viet Pham

Reputation: 214

You can use the built in method of ruby: execute_script with a script to change element attribute. ie:

 driver.execute_script("arguments[0].setAttribute('data-scene_cd', 'abc');",[Element])

Attribute Change: https://www.w3schools.com/jsref/met_element_setattribute.asp

Execute Script Ruby: http://www.rubydoc.info/gems/selenium-webdriver/0.0.28/Selenium/WebDriver/Driver#execute_script-instance_method

Upvotes: 2

Related Questions