[Webtest] Asynchronous requests: how to track?

Andrew Sickorsky andrew.sickorsky@texunatech.com
Mon, 03 Sep 2007 18:08:14 +0400


This is a multi-part message in MIME format.
--------------020305090009070207020105
Content-Type: multipart/alternative;
 boundary="------------050707030609030404040107"


--------------050707030609030404040107
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hello, Marc!
First thanks for you to point at unsafe construction: this text was 
presented in HTML. But the problem still persists:
I've re-wrote test as follows:
<retry maxcount="20" description="wait while spreadsheet is importing">
        <sleep seconds="6"/>

                <verifyText text="Importing data ..."/>

    </retry>
'Importing data' text is added by java script during process and doesn't 
hardly located in any page. Then i think that this (dynamic) text 
shouldn't be located by HtmlUnit (at least verified by verifyText), so I 
rewrite test:
<retry maxcount="20" description="wait while spreadsheet is importing">
        <sleep seconds="6"/>

                <verifyTitle text="Bitcut - View data"/>

    </retry>
Ideally should track that page (by auto-redirect) changes to necessary 
view (this can be seen in a common browser).
I've switched to Debug mode in log output: seems that file uploaded 
sucessfully, but for some reason HtmlUnit doesn't load new page. So, i 
have no idea how I could track such processes in our app.

King regards for your patience
Andrew
> Hi Andrew,
>
> ups, I see now that your test is not safe:
>   <verifyText text="Please wait while your feed is being imported."/>
> verifies that this text is contained in server response of the current
> page. This means that it can be at any place in the html file and, that
> it is there even before you click the upload button, and if you use
> AJAX, it will still be there once the request has been processed.
>
> You should configure the log to "see" if the AJAX call occured. And you
> can probably look at the logs of your server too.
>
> Marc.
>
> Andrew Sickorsky wrote:
>   
>> Hi, Marc!
>> Thanks for the answer. But it seems that this didn't work for me. So,
>> I've included code:
>>    <groovy>
>>        import
>> com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController
>>        step.context.webClient.ajaxController = new
>>            NicelyResynchronizingAjaxController()
>>    </groovy>
>>
>> The text code is:
>>    <clickElement
>> xpath="//ul[@class='dashboard-icons']/li[@class='import_excel']"/>
>>    <setFileField
>> xpath="//div[@id='import-excel']//input[@class='field']"
>> fileName="${analysis-test-web.dir}/testdata/${excel.name}"/>
>>    <clickElement
>> xpath="//div[@id='import-excel']//input[@class='upload-button']"/>
>>    <retry maxcount="40" description="wait while spreadsheet is importing">
>>        <sleep seconds="6"/>
>>          <not>
>>            <verifyText text="Please wait while your feed is being
>> imported."/>
>>          </not>
>>        <sleep seconds="6"/>
>>    </retry>
>>    <verifyText text="Your data have been successfully imported."/>
>>    <clickElement xpath="//div[@class='buttons']/input[@alt='Close']"/>
>>
>> but this All nested steps 'retried without success'. Total time for
>> uploading: 40*60=240 seconds = 4 minutes is enough for testing s/s. I've
>> tested this with 'Seconds' parameter equal to '30' (30*40 = 1200
>> seconds) but result remains the same.
>>     
>>> Hi Andrew,
>>>
>>> can you try this (with a recent build containing HtmlUnit 1.13):
>>>
>>> <groovy>
>>> import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController
>>> step.context.webClient.ajaxController = new
>>> NicelyResynchronizingAjaxController()
>>> </groovy>
>>>
>>> this will be the default setting for WebTest... once I've found time
>>> for it.
>>>
>>> More about the motivation of this resynchronization:
>>> http://mguillem.wordpress.com/2007/07/24/htmlunit-re-synchronize-ajax-calls-for-simple-deterministic-test-automation/
>>>
>>>
>>> Marc.
>>>   
>>>       
>
>
>   


--------------050707030609030404040107
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hello, Marc!<br>
First thanks for you to point at unsafe construction: this text was
presented in HTML. But the problem still persists: <br>
I've re-wrote test as follows:<br>
&lt;retry maxcount="20" description="wait while spreadsheet is
importing"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;sleep seconds="6"/&gt;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;verifyText text="Importing data ..."/&gt;<br>
<br>
&nbsp;&nbsp;&nbsp; &lt;/retry&gt;<br>
'Importing data' text is added by java script during process and
doesn't hardly located in any page. Then i think that this (dynamic)
text shouldn't be located by HtmlUnit (at least verified by
verifyText), so I rewrite test:<br>
&lt;retry maxcount="20" description="wait while spreadsheet is
importing"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;sleep seconds="6"/&gt;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;verifyTitle text="Bitcut - View data"/&gt;<br>
<br>
&nbsp;&nbsp;&nbsp; &lt;/retry&gt;<br>
Ideally should track that page (by auto-redirect) changes to necessary
view (this can be seen in a common browser). <br>
I've switched to Debug mode in log output: seems that file uploaded
sucessfully, but for some reason HtmlUnit doesn't load new page. So, i
have no idea how I could track such processes in our app.<br>
<br>
King regards for your patience<br>
Andrew<br>
<blockquote cite="mid:46D6ADF7.7050206@yahoo.fr" type="cite">
  <pre wrap="">Hi Andrew,

ups, I see now that your test is not safe:
  &lt;verifyText text="Please wait while your feed is being imported."/&gt;
verifies that this text is contained in server response of the current
page. This means that it can be at any place in the html file and, that
it is there even before you click the upload button, and if you use
AJAX, it will still be there once the request has been processed.

You should configure the log to "see" if the AJAX call occured. And you
can probably look at the logs of your server too.

Marc.

Andrew Sickorsky wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Hi, Marc!
Thanks for the answer. But it seems that this didn't work for me. So,
I've included code:
   &lt;groovy&gt;
       import
com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController
       step.context.webClient.ajaxController = new
           NicelyResynchronizingAjaxController()
   &lt;/groovy&gt;

The text code is:
   &lt;clickElement
xpath="//ul[@class='dashboard-icons']/li[@class='import_excel']"/&gt;
   &lt;setFileField
xpath="//div[@id='import-excel']//input[@class='field']"
fileName="${analysis-test-web.dir}/testdata/${excel.name}"/&gt;
   &lt;clickElement
xpath="//div[@id='import-excel']//input[@class='upload-button']"/&gt;
   &lt;retry maxcount="40" description="wait while spreadsheet is importing"&gt;
       &lt;sleep seconds="6"/&gt;
         &lt;not&gt;
           &lt;verifyText text="Please wait while your feed is being
imported."/&gt;
         &lt;/not&gt;
       &lt;sleep seconds="6"/&gt;
   &lt;/retry&gt;
   &lt;verifyText text="Your data have been successfully imported."/&gt;
   &lt;clickElement xpath="//div[@class='buttons']/input[@alt='Close']"/&gt;

but this All nested steps 'retried without success'. Total time for
uploading: 40*60=240 seconds = 4 minutes is enough for testing s/s. I've
tested this with 'Seconds' parameter equal to '30' (30*40 = 1200
seconds) but result remains the same.
    </pre>
    <blockquote type="cite">
      <pre wrap="">Hi Andrew,

can you try this (with a recent build containing HtmlUnit 1.13):

&lt;groovy&gt;
import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController
step.context.webClient.ajaxController = new
NicelyResynchronizingAjaxController()
&lt;/groovy&gt;

this will be the default setting for WebTest... once I've found time
for it.

More about the motivation of this resynchronization:
<a class="moz-txt-link-freetext" href="http://mguillem.wordpress.com/2007/07/24/htmlunit-re-synchronize-ajax-calls-for-simple-deterministic-test-automation/">http://mguillem.wordpress.com/2007/07/24/htmlunit-re-synchronize-ajax-calls-for-simple-deterministic-test-automation/</a>


Marc.
  
      </pre>
    </blockquote>
  </blockquote>
  <pre wrap=""><!---->

  </pre>
</blockquote>
<br>
</body>
</html>

--------------050707030609030404040107--

--------------020305090009070207020105
Content-Type: text/x-vcard; charset=utf-8;
 name="andrew.sickorsky.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="andrew.sickorsky.vcf"

begin:vcard
fn:Andrew Sickorsky
n:Sickorsky;Andrew
org:Texuna Tech Ltd.
adr;dom:;;Magistralnaya street, 5 - 33;Moscow
email;internet:andrew.sickorsky@texunatech.com
title:Tester
tel;work:+7 495 9809067
tel;cell:+7 909 9070328
x-mozilla-html:TRUE
url:www.texunatech.com
version:2.1
end:vcard


--------------020305090009070207020105--