Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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
share|improve this question
    
There are a couple of answers to this question (including one from me) here groups.google.com/d/topic/watir-general/CVE4yznlYcs/discussion –  Željko Filipin Jul 15 '13 at 9:33
add comment

1 Answer 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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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