Home > Blockchain >  Watir Set value of input type="text"
Watir Set value of input type="text"

Time:04-22

I am trying to set an email into this span but I'm having trouble selecting it and updating it. The span id is created dynamically but the class is not

<div >

    <span id="foundation-text-input-3535" >Email*</span>

    <input type="text" aria-labelledby="foundation-text-input-3535" placeholder="" value="" autocomplete="off" data-qa="email_input"></div>

CodePudding user response:

it should be getting set via the input element, not the span, right?

browser.text_field(data_qa: 'email_input').set email_address

You can also use regular expressions as well if you need to locate things that way:

browser.span(id: /foundation-text-input/)

Results from irb:

irb(main):001:0> require 'watir'
=> true
irb(main):002:0> browser = Watir::Browser.new
=> #<Watir::Browser:0x6e1ac1ec79323ad4 url="data:," title="">
irb(main):003:0> browser.goto "https://portal.sysco.com/login"
=> "https://portal.sysco.com/login"
irb(main):004:0> browser.text_field(data_qa: 'email_input').set "test"
=> nil
irb(main):005:0> browser.text_field(data_qa: 'email_input').value
=> "test"
  • Related