Problem using Webtest and DOM tree's

View: New views
9 Messages — Rating Filter:   Alert me  

Problem using Webtest and DOM tree's

by tom hanekamp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi there
 
Before I asign my problem, I must admit that I`m not a pro in webtest.
 
The website or rather webapplication that I`m trying to test contains a hierarchy of items coming from a database. The moment you click one of the items, the page will show some textual information regarding the item you click.
 
The problem is that when I`m trying to get webtest to select one of the items, so I can test if the webapplication does indeed display the right information, I always get failed results saying they cannot find the item within the page.
 
Is there a way for me to have webtest reach these items?
 
Many thanks
 
Tom


What can you do with the new Windows Live? Find out

Re: Problem using Webtest and DOM tree's

by Angel Merrett :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Tom - have you checked the source for the page to see if the item you
are looking for actually does exist?  If it doesn't exist in the
source then it's likely dynamically created using javascript.  I have
the same issue and have not yet been able to resolve it so if you find
a way, please share! :)

Angel

On Thu, Oct 8, 2009 at 6:05 AM, tom hanekamp <tom_hanekamp@...> wrote:

> Hi there
>
> Before I asign my problem, I must admit that I`m not a pro in webtest.
>
> The website or rather webapplication that I`m trying to test contains
> a hierarchy of items coming from a database. The moment you click one of the
> items, the page will show some textual information regarding the item you
> click.
>
> The problem is that when I`m trying to get webtest to select one of the
> items, so I can test if the webapplication does indeed display the right
> information, I always get failed results saying they cannot find the item
> within the page.
>
> Is there a way for me to have webtest reach these items?
>
> Many thanks
>
> Tom
>
> ________________________________
> What can you do with the new Windows Live? Find out



--
Hanlon's Razor: ``Never attribute to malice that which can be
adequately explained by stupidity''.
_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest

RE: Problem using Webtest and DOM tree's

by Tim Pezarro :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Tom,

This is a method I use which may work for you:

Use storeRegEx to find something unique about the url for the item you wish to click. In my example, I have an argument called cat_id which is used by the script addCategory.pl. Store that in a dynamic property as in the example below called active.category

        <storeRegEx group="1"
        text="addCategory.pl\?cat_id=([0-9]{1,6})&action=edit">Edit</a></td><td>LicCatAddRemove#{random.category}${server.name}"
        property="active.category"/>

Use the clickLink step with the combination of href and label. This functions like an "and" to match the link that has a href containing the text "cat_id=12543" (assuming the result of the match from the storeRegEx step above was "12543") and a label text "Edit".

        <clickLink href="cat_id=#{active.category}" label="Edit"/>

This allows me to select a particular link from a table of links that all have a link labelled "Edit" with a URL using a id number as an argument that I can get by inspecting the page with storeRegEx.

I probably don't need the label portion because webtest would look for the first match of a href field with "cat_id=12543" which is likely unique.

Cheers,

Tim Pezarro
Manager, Web Services
tim_pezarro@...
Phone: +1-604-415-6044
Cell: +1-604-762-1000
Fax: +1-604-415-6602
PMC-Sierra, Inc.
100-2700 Production Way
Burnaby, BC, Canada
V5A 4X1



> -----Original Message-----
> From: webtest-admin@...
> [mailto:webtest-admin@...] On Behalf Of Angel Merrett
> Sent: Thursday, October 08, 2009 5:07 AM
> To: webtest@...; tom hanekamp
> Subject: Re: [Webtest] Problem using Webtest and DOM tree's
>
> Tom - have you checked the source for the page to see if the
> item you are looking for actually does exist?  If it doesn't
> exist in the source then it's likely dynamically created
> using javascript.  I have the same issue and have not yet
> been able to resolve it so if you find a way, please share! :)
>
> Angel
>
> On Thu, Oct 8, 2009 at 6:05 AM, tom hanekamp
> <tom_hanekamp@...> wrote:
> > Hi there
> >
> > Before I asign my problem, I must admit that I`m not a pro
> in webtest.
> >
> > The website or rather webapplication that I`m trying to
> test contains
> > a hierarchy of items coming from a database. The moment you
> click one
> > of the items, the page will show some textual information regarding
> > the item you click.
> >
> > The problem is that when I`m trying to get webtest to select one of
> > the items, so I can test if the webapplication does indeed
> display the
> > right information, I always get failed results saying they
> cannot find
> > the item within the page.
> >
> > Is there a way for me to have webtest reach these items?
> >
> > Many thanks
> >
> > Tom
> >
> > ________________________________
> > What can you do with the new Windows Live? Find out
>
>
>
> --
> Hanlon's Razor: ``Never attribute to malice that which can be
> adequately explained by stupidity''.
> _______________________________________________
> WebTest mailing list
> WebTest@...
> http://lists.canoo.com/mailman/listinfo/webtest
>
_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest

RE: Problem using Webtest and DOM tree's

by WSoula :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is it possible this stuff is created using ajax for you guys?  If so you can use a sleep to wait for it to load and then check it with xpath.  For example, I have an inputField that is loaded with ajax after clicking a button.  If I have webtest click the button then set the inputField it will fail not being able to find the input field.  But if I have webtest click the button sleep for 5 seconds then set the inputField it is able to find it as ajax loaded it while webtest was sleeping.  Taken a step farther you can make a macro that takes an element and do a retry on the element sleeping between retries.  Then all you have to do is pass a verifyXPath step for whatever will load with ajax to the macro and it will keep trying till it is loaded.

-----Original Message-----
From: webtest-admin@... [mailto:webtest-admin@...] On Behalf Of Angel Merrett
Sent: Thursday, October 08, 2009 7:07 AM
To: webtest@...; tom hanekamp
Subject: Re: [Webtest] Problem using Webtest and DOM tree's

Tom - have you checked the source for the page to see if the item you
are looking for actually does exist?  If it doesn't exist in the
source then it's likely dynamically created using javascript.  I have
the same issue and have not yet been able to resolve it so if you find
a way, please share! :)

Angel

On Thu, Oct 8, 2009 at 6:05 AM, tom hanekamp <tom_hanekamp@...> wrote:

> Hi there
>
> Before I asign my problem, I must admit that I`m not a pro in webtest.
>
> The website or rather webapplication that I`m trying to test contains
> a hierarchy of items coming from a database. The moment you click one of the
> items, the page will show some textual information regarding the item you
> click.
>
> The problem is that when I`m trying to get webtest to select one of the
> items, so I can test if the webapplication does indeed display the right
> information, I always get failed results saying they cannot find the item
> within the page.
>
> Is there a way for me to have webtest reach these items?
>
> Many thanks
>
> Tom
>
> ________________________________
> What can you do with the new Windows Live? Find out



--
Hanlon's Razor: ``Never attribute to malice that which can be
adequately explained by stupidity''.
_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest
_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest

Re: Problem using Webtest and DOM tree's

by Stephan Robotta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Thu, Oct 08, 2009 at 02:44:55PM -0500, Soula, William wrote:
> Is it possible this stuff is created using ajax for you guys?  If so
> you can use a sleep to wait for it to load and then check it with
> xpath.

Instead of sleeping a certain time you can do the check in a loop and
sleep one second only. That saves you time if your request is a lot
shorter that the aproximated 5 seconds and also if a request hangs once
you wont get a failure.

I use this macro to check for an xpath that must be exist after the
response from an ajax call was reveived:

<macrodef name="checkAjaxResponseXpathRegex" description="check
response of an ajax request">
    <attribute name="description" />
    <attribute name="xpath" />
    <attribute name="regex" />
    <sequential>
        <retry maxcount="10">
            <sleep seconds="1"/>
            <verifyXPath
              description="@{description}"
              xpath="@{xpath}"
              regex="@{regex}"
            />  
        </retry>
    </sequential>  
</macrodef>

Inside the webtest I do this:

<setSelectField
  description="Select some value"
  xpath="//select[@id='some_id']"
  value="some_val"
/>
<checkAjaxResponseXpathText
  description="check result after ajax call"
  xpath="//div[@id='some_id']/ol/li[4]/a"
  text="Sometext"
/>  

With this mechanism I can test most of the Ajax stuff inside a page
that changes the DOM tree when the response is received.

Best regards, Stephan
_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest

Parent Message unknown Re: Problem using Webtest and DOM tree's

by WSoula :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Re: [Webtest] Problem using Webtest and DOM tree's Thanks Stephan for the example for:
>Taken a step farther you can make a macro that takes an element and do a retry on the element sleeping between retries.  Then all you >have to do is pass a verifyXPath step for whatever will load with ajax to the macro and it will keep trying till it is loaded.

Truly examples are better than sentences, so, I'll include mine as it is a little different than Stephan's:
<macrodef name="ajaxLoad">
               <element name="value" implicit="yes"/>
               <sequential>
                       <retry maxcount="30">
                               <sleep seconds="1"/>
                               <value/>
                       </retry>
               </sequential>
       </macrodef>

<ajaxLoad>
       <verifyXPath xpath="//table[@id='ajaxLoadTable']" description="Wait for ajax to load"/>
</ajaxLoad>

This way you can also use webtest steps to verify when ajax is loaded so you could do:
<ajaxLoad>
       <verifyInputField name="valueSetWithAjax" value="100" description="Wait for ajax to load"/>
</ajaxLoad>
 --------------------------------------------------------
 
Hi,

On Thu, Oct 08, 2009 at 02:44:55PM -0500, Soula, William wrote:
> Is it possible this stuff is created using ajax for you guys?  If so
> you can use a sleep to wait for it to load and then check it with
> xpath.

Instead of sleeping a certain time you can do the check in a loop and
sleep one second only. That saves you time if your request is a lot
shorter that the aproximated 5 seconds and also if a request hangs once
you wont get a failure.

I use this macro to check for an xpath that must be exist after the
response from an ajax call was reveived:

<macrodef name="checkAjaxResponseXpathRegex" description="check
response of an ajax request">
    <attribute name="description" />
    <attribute name="xpath" />
    <attribute name="regex" />
    <sequential>
        <retry maxcount="10">
            <sleep seconds="1"/>
            <verifyXPath
              description="@{description}"
              xpath="@{xpath}"
              regex="@{regex}"
            /> 
        </retry>
    </sequential>  
</macrodef>

Inside the webtest I do this:

<setSelectField
  description="Select some value"
  xpath="//select[@id='some_id']"
  value="some_val"
/>
<checkAjaxResponseXpathText
  description="check result after ajax call"
  xpath="//div[@id='some_id']/ol/li[4]/a"
  text="Sometext"
/> 

With this mechanism I can test most of the Ajax stuff inside a page
that changes the DOM tree when the response is received.

Best regards, Stephan
_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest

Re: Problem using Webtest and DOM tree's

by Marc Guillemot :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

instead of sleeping or retrying, you can use
<config easyajax="true"/>
which works fine for a lot of AJAX libraries... but not all :-(

Cheers,
Marc.

Soula, William a écrit :

> Thanks Stephan for the example for:
>>Taken a step farther you can make a macro that takes an element and do a
> retry on the element sleeping between retries.  Then all you >have to do
> is pass a verifyXPath step for whatever will load with ajax to the macro
> and it will keep trying till it is loaded.
>
> Truly examples are better than sentences, so, I'll include mine as it is
> a little different than Stephan's:
> <macrodef name="ajaxLoad">
>                <element name="value" implicit="yes"/>
>                <sequential>
>                        <retry maxcount="30">
>                                <sleep seconds="1"/>
>                                <value/>
>                        </retry>
>                </sequential>
>        </macrodef>
>
> <ajaxLoad>
>        <verifyXPath xpath="//table[@id='ajaxLoadTable']"
> description="Wait for ajax to load"/>
> </ajaxLoad>
>
> This way you can also use webtest steps to verify when ajax is loaded so
> you could do:
> <ajaxLoad>
>        <verifyInputField name="valueSetWithAjax" value="100"
> description="Wait for ajax to load"/>
> </ajaxLoad>
>  --------------------------------------------------------
>  
> Hi,
>
> On Thu, Oct 08, 2009 at 02:44:55PM -0500, Soula, William wrote:
>>  Is it possible this stuff is created using ajax for you guys?  If so
>>  you can use a sleep to wait for it to load and then check it with
>>  xpath.
>
> Instead of sleeping a certain time you can do the check in a loop and
> sleep one second only. That saves you time if your request is a lot
> shorter that the aproximated 5 seconds and also if a request hangs once
> you wont get a failure.
>
> I use this macro to check for an xpath that must be exist after the
> response from an ajax call was reveived:
>
> <macrodef name="checkAjaxResponseXpathRegex" description="check
> response of an ajax request">
>     <attribute name="description" />
>     <attribute name="xpath" />
>     <attribute name="regex" />
>     <sequential>
>         <retry maxcount="10">
>             <sleep seconds="1"/>
>             <verifyXPath
>               description="@{description}"
>               xpath="@{xpath}"
>               regex="@{regex}"
>             />
>         </retry>
>     </sequential>  
> </macrodef>
>
> Inside the webtest I do this:
>
> <setSelectField
>   description="Select some value"
>   xpath="//select[@id='some_id']"
>   value="some_val"
> />
> <checkAjaxResponseXpathText
>   description="check result after ajax call"
>   xpath="//div[@id='some_id']/ol/li[4]/a"
>   text="Sometext"
> />
>
> With this mechanism I can test most of the Ajax stuff inside a page
> that changes the DOM tree when the response is received.
>
> Best regards, Stephan
> _______________________________________________
> WebTest mailing list
> WebTest@...
> http://lists.canoo.com/mailman/listinfo/webtest


_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest

Ajax calls and IFrame

by Ali, Haneef :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have the following scenario which is not working in webtest. Can you  please let me know how to handle this?


OnButtonClick(){

    Change the src attribute of IFrame. This is used to record the history in the browser. This triggers a HTTP Get to a static page
    Send a HTTP request using XMLHttpRequest object  

}


Webtest considers the HTTP Get response triggered by IFrame as the response of OnButtonClick.  It ignores the response from the XMLHTTPRequest object.
Any idea how to fix this?

BTW I'm using : R_1786

Thanks,
Haneef


-----Original Message-----
From: webtest-admin@... [mailto:webtest-admin@...] On Behalf Of Marc Guillemot
Sent: Monday, October 12, 2009 11:13 PM
To: webtest@...
Subject: Re: [Webtest] Problem using Webtest and DOM tree's

Hi,

instead of sleeping or retrying, you can use
<config easyajax="true"/>
which works fine for a lot of AJAX libraries... but not all :-(

Cheers,
Marc.

Soula, William a écrit :

> Thanks Stephan for the example for:
>>Taken a step farther you can make a macro that takes an element and do a
> retry on the element sleeping between retries.  Then all you >have to do
> is pass a verifyXPath step for whatever will load with ajax to the macro
> and it will keep trying till it is loaded.
>
> Truly examples are better than sentences, so, I'll include mine as it is
> a little different than Stephan's:
> <macrodef name="ajaxLoad">
>                <element name="value" implicit="yes"/>
>                <sequential>
>                        <retry maxcount="30">
>                                <sleep seconds="1"/>
>                                <value/>
>                        </retry>
>                </sequential>
>        </macrodef>
>
> <ajaxLoad>
>        <verifyXPath xpath="//table[@id='ajaxLoadTable']"
> description="Wait for ajax to load"/>
> </ajaxLoad>
>
> This way you can also use webtest steps to verify when ajax is loaded so
> you could do:
> <ajaxLoad>
>        <verifyInputField name="valueSetWithAjax" value="100"
> description="Wait for ajax to load"/>
> </ajaxLoad>
>  --------------------------------------------------------
>  
> Hi,
>
> On Thu, Oct 08, 2009 at 02:44:55PM -0500, Soula, William wrote:
>>  Is it possible this stuff is created using ajax for you guys?  If so
>>  you can use a sleep to wait for it to load and then check it with
>>  xpath.
>
> Instead of sleeping a certain time you can do the check in a loop and
> sleep one second only. That saves you time if your request is a lot
> shorter that the aproximated 5 seconds and also if a request hangs once
> you wont get a failure.
>
> I use this macro to check for an xpath that must be exist after the
> response from an ajax call was reveived:
>
> <macrodef name="checkAjaxResponseXpathRegex" description="check
> response of an ajax request">
>     <attribute name="description" />
>     <attribute name="xpath" />
>     <attribute name="regex" />
>     <sequential>
>         <retry maxcount="10">
>             <sleep seconds="1"/>
>             <verifyXPath
>               description="@{description}"
>               xpath="@{xpath}"
>               regex="@{regex}"
>             />
>         </retry>
>     </sequential>  
> </macrodef>
>
> Inside the webtest I do this:
>
> <setSelectField
>   description="Select some value"
>   xpath="//select[@id='some_id']"
>   value="some_val"
> />
> <checkAjaxResponseXpathText
>   description="check result after ajax call"
>   xpath="//div[@id='some_id']/ol/li[4]/a"
>   text="Sometext"
> />
>
> With this mechanism I can test most of the Ajax stuff inside a page
> that changes the DOM tree when the response is received.
>
> Best regards, Stephan
> _______________________________________________
> WebTest mailing list
> WebTest@...
> http://lists.canoo.com/mailman/listinfo/webtest


_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest
_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest

Re: Ajax calls and IFrame

by Marc Guillemot :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

a workaround would probably be to use followFrame. To really fix it, a
minimal test case would be needed to reproduce the problem.

Cheers,
Marc.

Ali, Haneef a écrit :

> Hi,
>
> I have the following scenario which is not working in webtest. Can you  please let me know how to handle this?
>
>
> OnButtonClick(){
>
>     Change the src attribute of IFrame. This is used to record the history in the browser. This triggers a HTTP Get to a static page
>     Send a HTTP request using XMLHttpRequest object  
>
> }
>
>
> Webtest considers the HTTP Get response triggered by IFrame as the response of OnButtonClick.  It ignores the response from the XMLHTTPRequest object.
> Any idea how to fix this?
>
> BTW I'm using : R_1786
>
> Thanks,
> Haneef
>
>
> -----Original Message-----
> From: webtest-admin@... [mailto:webtest-admin@...] On Behalf Of Marc Guillemot
> Sent: Monday, October 12, 2009 11:13 PM
> To: webtest@...
> Subject: Re: [Webtest] Problem using Webtest and DOM tree's
>
> Hi,
>
> instead of sleeping or retrying, you can use
> <config easyajax="true"/>
> which works fine for a lot of AJAX libraries... but not all :-(
>
> Cheers,
> Marc.
>
> Soula, William a écrit :
>> Thanks Stephan for the example for:
>>> Taken a step farther you can make a macro that takes an element and do a
>> retry on the element sleeping between retries.  Then all you >have to do
>> is pass a verifyXPath step for whatever will load with ajax to the macro
>> and it will keep trying till it is loaded.
>>
>> Truly examples are better than sentences, so, I'll include mine as it is
>> a little different than Stephan's:
>> <macrodef name="ajaxLoad">
>>                <element name="value" implicit="yes"/>
>>                <sequential>
>>                        <retry maxcount="30">
>>                                <sleep seconds="1"/>
>>                                <value/>
>>                        </retry>
>>                </sequential>
>>        </macrodef>
>>
>> <ajaxLoad>
>>        <verifyXPath xpath="//table[@id='ajaxLoadTable']"
>> description="Wait for ajax to load"/>
>> </ajaxLoad>
>>
>> This way you can also use webtest steps to verify when ajax is loaded so
>> you could do:
>> <ajaxLoad>
>>        <verifyInputField name="valueSetWithAjax" value="100"
>> description="Wait for ajax to load"/>
>> </ajaxLoad>
>>  --------------------------------------------------------
>>  
>> Hi,
>>
>> On Thu, Oct 08, 2009 at 02:44:55PM -0500, Soula, William wrote:
>>>  Is it possible this stuff is created using ajax for you guys?  If so
>>>  you can use a sleep to wait for it to load and then check it with
>>>  xpath.
>> Instead of sleeping a certain time you can do the check in a loop and
>> sleep one second only. That saves you time if your request is a lot
>> shorter that the aproximated 5 seconds and also if a request hangs once
>> you wont get a failure.
>>
>> I use this macro to check for an xpath that must be exist after the
>> response from an ajax call was reveived:
>>
>> <macrodef name="checkAjaxResponseXpathRegex" description="check
>> response of an ajax request">
>>     <attribute name="description" />
>>     <attribute name="xpath" />
>>     <attribute name="regex" />
>>     <sequential>
>>         <retry maxcount="10">
>>             <sleep seconds="1"/>
>>             <verifyXPath
>>               description="@{description}"
>>               xpath="@{xpath}"
>>               regex="@{regex}"
>>             />
>>         </retry>
>>     </sequential>  
>> </macrodef>
>>
>> Inside the webtest I do this:
>>
>> <setSelectField
>>   description="Select some value"
>>   xpath="//select[@id='some_id']"
>>   value="some_val"
>> />
>> <checkAjaxResponseXpathText
>>   description="check result after ajax call"
>>   xpath="//div[@id='some_id']/ol/li[4]/a"
>>   text="Sometext"
>> />
>>
>> With this mechanism I can test most of the Ajax stuff inside a page
>> that changes the DOM tree when the response is received.
>>
>> Best regards, Stephan
>> _______________________________________________
>> WebTest mailing list
>> WebTest@...
>> http://lists.canoo.com/mailman/listinfo/webtest
>
>
> _______________________________________________
> WebTest mailing list
> WebTest@...
> http://lists.canoo.com/mailman/listinfo/webtest
> _______________________________________________
> WebTest mailing list
> WebTest@...
> http://lists.canoo.com/mailman/listinfo/webtest
>

_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest