2

I am writing the registration script where the API is being called in company registration no field and it fetches all the data regarding company and fill it automatically in according field like name, phone no, address etc. So i want to make the script wait until all text-fields are filled with values. I have tried the following script but it doesn't wait and clicks on continue button before all the values are fetched.

require "watir-webdriver"
require "watir-webdriver/wait"

br = Watir::Browser.new :chrome
br.goto verification_link

br.a(:text => "Continue Manually").flash
br.a(:text => "Continue Manually").click
br.text_field(:id => "regNumber").flash
br.text_field(:id => "regNumber").set "03977902"
br.button(:id => "populatebtn").flash
br.button(:id => "populatebtn").click

Watir::Wait.until(10) {br.text_field(:id => "companyName").value.exists?}

br.select_list(:id => "companyType").flash
br.select_list(:id => "companyType").select("Limited")
br.select_list(:id => "nature").flash
br.select_list(:id => "nature").select("Art")
br.text_field(:id => "sales_turnover").flash
br.text_field(:id => "sales_turnover").set "12000"
br.select_list(:id => "why").flash
br.select_list(:id => "why").select("Bill Payment")
br.button(:id => "lookup").flash
br.button(:id => "lookup").click
br.button(:id => "continue").flash
br.button(:id => "continue").click
1

1 Answer 1

1

Maulik,

Instead of waiting until a value exists, how about trying something along the following lines:

br.wait_until{br.text_field(:id=> 'companyName').text.eql?("") == false}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.