Make Watir-webdriver to load a page for limited time and to be able to retrieve information later -


i know there several questions related implementation of waiting , timeouts in watir, have not found answer problem (which must common). use watir-webdriver testing of page due ajax implementation loads portion-by-portion long time (more 5 min). need able sample page limited time (20-40 sec) , able analyze information loaded during short time. however, know, there no straightforward direct mechanism tell watir::browser stop. can use timeout, although script gets control after rescue, impossible interrogate browser , verify information able received during timeout window. can @ point kill process , restart browser discussed here: make headless browser stop loading page , elsewhere.

the code below illustrates situation. in example have global timeout (30 sec) , local timeout (15 sec) used reading page. never gets b.text call; script outputs first exception after 15 sec , keeps waiting browser released , after global timeout of 30 sec prints second exception message.

time out. got exception branch  dropped bottom rescue.  end. 

i tried send 'escape' key browser, communication while in goto method impossible. tips , suggestions appreciated!

require 'watir-webdriver' require 'timeout'  client = selenium::webdriver::remote::http::default.new client.timeout = 30                      # set global timeout   b = watir::browser.new :chrome, :http_client => client my_url = '...here address...'  begin   begin    timeout::timeout(15) { b.goto my_url } # access page local timeout    b.close # if unbelievably , page loaded    rescue exception => e     puts 'time out. got exception branch'      if b.text.include? 'my_text'   # never gets here       puts 'yes, see text!'     else       puts 'i not see text.'     end   end rescue exception => e  puts 'dropped bottom rescue.' end  puts 'the end.' 

watir relies on selenium webdriver handle calls browser. @ time browsers require document.readystate of current frame return "complete" before returning control code.

a recent update webdriver specification appears allow possibility of browser driver implementing page loading strategy not blocking, not requirement , not supported @ time.

https://w3c.github.io/webdriver/webdriver-spec.html#the-page-load-strategy


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -