Looking for help running Groovy in Canoo Webtest

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

Looking for help running Groovy in Canoo Webtest

by Zepernick David :: 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, my name is David
 
I work for John Deere Agri Services and I am a member of development team that is building business solutions for the agricultural industry.
 
I am , more specifically, a part of the QA group. Not a lot of programming  experience myself but have programmers available to me although their time is limitted.
 
This year our development group decided to give Canoo Webtest a try.
 
I have become familiar with Canoo Webtest and have been able to write automated test scripts.
 
We as a team have had some success but have run into a few problems that have limitted what we can do with Canoo Webtest.
 
I am hoping to get a little direction from someone that has experience with Canoo Webtest.
 
 
 
 
Problem #1
Javascript errors  -  Controls that are incorporated to some of our webpages that are written in javascript cause errors when running the scripts and prevent us from saving pages.
 
 
The error messages look like this:
: TypeError: Cannot find function extend in object function Object()
{ [native code for Object.Object, arity=1] } .
.Home,Jdas.Applications.ExtendAg.Base.UI.ashx#8)
 
Problem #2
In attempting to incorporate groovy script into our scripts. Groovy code doesn’t seem to work.
Eclipse is our IDE , btw .
Is there a simple example of a Canoo webtest script that incorporates the <groovy> tags with simple groovy code that will produce some results that I can use to verify that I have everything working properly (somewhere out on the internet)? The example on the canoo site didn’t work as is.
 
Im not sure my configuration is correct in Eclipse.I had to manually add the plugin using a zip file because the software update feature didn’t work.
 
Can you refer me to any documentation that might get me started
 
Im not even sure this is the right approach. Is Canoo Webtest commonly used this way or is it better to right groovy scripts that refer to Canoo webtest commands?
 
Any help would be appreciated.
 

Re: Looking for help running Groovy in Canoo Webtest

by aldana :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i am using groovy and no xml stuff. groovy feels much more like test
scripting as this programming in xml horror.

it is quite straighforward to setup though i used maven (which gives you
an easier ramp-up). it took me roughly half a day, the major problem i
had was the configuration step inside groovy (see
http://www.nabble.com/using-option-step-in-groovy-syntax-td24134316.html).
the post also explains the handling of the java-script error message.

as a starter have a look at:
http://groovy.dzone.com/news/webtest-groovy-maven-and

don't know about eclipse, i am using fantastic IntelliJ IDEA which has
great groovy support and IDE integration was smoothly.


Zepernick David schrieb:

> Hi, my name is David
> I work for John Deere Agri Services and I am a member of development
> team that is building business solutions for the agricultural industry.
> I am , more specifically, a part of the QA group. Not a lot of
> programming experience myself but have programmers available to me
> although their time is limitted.
> This year our development group decided to give Canoo Webtest a try.
> I have become familiar with Canoo Webtest and have been able to write
> automated test scripts.
> We as a team have had some success but have run into a few problems
> that have limitted what we can do with Canoo Webtest.
> I am hoping to get a little direction from someone that has experience
> with Canoo Webtest.
> Problem #1
> Javascript errors - Controls that are incorporated to some of our
> webpages that are written in javascript cause errors when running the
> scripts and prevent us from saving pages.
> The error messages look like this:
> JavaScript error loading page
> _https://eaqa.jdas.deere.com/Base/Home.aspx?tabcode=HOME&bppik=1_
> <https://eaqa.jdas.deere.com/Base/Home.aspx?tabcode=HOME&bppik=1>
> : TypeError: Cannot find function extend in object function Object()
> { [native code for Object.Object, arity=1] } .
> (_https://eaqa.jdas.deere.com/ajaxpro/Jdas.Applications.ExtendAg.Base.UI.Pages_
> .Home,Jdas.Applications.ExtendAg.Base.UI.ashx#8)
> Problem #2
> In attempting to incorporate groovy script into our scripts. Groovy
> code doesn’t seem to work.
> Eclipse is our IDE , btw .
> Is there a simple example of a Canoo webtest script that incorporates
> the <groovy> tags with simple groovy code that will produce some
> results that I can use to verify that I have everything working
> properly (somewhere out on the internet)? The example on the canoo
> site didn’t work as is.
> Im not sure my configuration is correct in Eclipse.I had to manually
> add the plugin using a zip file because the software update feature
> didn’t work.
> Can you refer me to any documentation that might get me started
> Im not even sure this is the right approach. Is Canoo Webtest commonly
> used this way or is it better to right groovy scripts that refer to
> Canoo webtest commands?
> Any help would be appreciated.


--
 manuel aldana
 aldana@...
 software-engineering blog: http://www.aldana-online.de

_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest
manuel aldana
aldana((at))gmx.de
software-engineering blog: http://www.aldana-online.de

Re: Looking for help running Groovy in Canoo Webtest

by Ian Homer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We've gone pure the pure groovy approach as well.  Would thoroughly  
recommend it.  I also got started with Marc Guillemot's blog @ http://mguillem.wordpress.com/2009/04/30/webtest-with-groovy-maven-and-eclipse/ 
   (I think it's the same as the one link on dzone) - excellent  
starting point.

If you're looking for an example of using groovy inside a groovy step  
you can do the following:

class ExampleTest extends WebtestCase {
   void test() {
     webtest("ExampleTest") {
       config(host:"blog.bemoko.com",port:80,haltonfailure:false)
       invoke "/2009/07/01/automated-mobile-web-testing-with-canoo-
webtest-were-impressed/"
       verifyTitle "Automated Mobile Web Testing with Canoo Webtest -  
we're impressed | bemoko's mobile web"
       groovy {
         println  
step.context.currentResponse.webResponse.contentAsString
         assert 1==1 : "1 should equal 1"
         assert 1==2 : "1 does not equal 2"
       }
     }
   }
}

the second assert will cause a failure just to show you what a failure  
looks like.  Although exceptions in groovy steps aren't reported  
clearly, they are marked as failures and if you follow the stack trace  
you can see what went wrong.  You can also interact with underlying  
Canoo (and subsequently HtmlUnit) APIs as I've done in the example  
above to dump the content.  We use this approach to do things like  
markup validation and hook into our own Java APIs.

Good luck with getting it all working, once you have it set up you  
won't look back.   Not sure about your JavaScript question, but if  
you've got other questions fire them in ...

Ian

On 1 Jul 2009, at 21:05, manuel aldana wrote:

> i am using groovy and no xml stuff. groovy feels much more like test  
> scripting as this programming in xml horror.
>
> it is quite straighforward to setup though i used maven (which gives  
> you an easier ramp-up). it took me roughly half a day, the major  
> problem i had was the configuration step inside groovy (see http://www.nabble.com/using-option-step-in-groovy-syntax-td24134316.html)
> . the post also explains the handling of the java-script error  
> message.
>
> as a starter have a look at:
> http://groovy.dzone.com/news/webtest-groovy-maven-and
>
> don't know about eclipse, i am using fantastic IntelliJ IDEA which  
> has great groovy support and IDE integration was smoothly.
>
>
> Zepernick David schrieb:
>> Hi, my name is David
>> I work for John Deere Agri Services and I am a member of  
>> development team that is building business solutions for the  
>> agricultural industry.
>> I am , more specifically, a part of the QA group. Not a lot of  
>> programming experience myself but have programmers available to me  
>> although their time is limitted.
>> This year our development group decided to give Canoo Webtest a try.
>> I have become familiar with Canoo Webtest and have been able to  
>> write automated test scripts.
>> We as a team have had some success but have run into a few problems  
>> that have limitted what we can do with Canoo Webtest.
>> I am hoping to get a little direction from someone that has  
>> experience with Canoo Webtest.
>> Problem #1
>> Javascript errors - Controls that are incorporated to some of our  
>> webpages that are written in javascript cause errors when running  
>> the scripts and prevent us from saving pages.
>> The error messages look like this:
>> JavaScript error loading page _https://eaqa.jdas.deere.com/Base/Home.aspx?tabcode=HOME&bppik=1_
>>  <https://eaqa.jdas.deere.com/Base/Home.aspx?tabcode=HOME&bppik=1>
>> : TypeError: Cannot find function extend in object function Object()
>> { [native code for Object.Object, arity=1] } .
>> (_https://eaqa.jdas.deere.com/ajaxpro/Jdas.Applications.ExtendAg.Base.UI.Pages_
>> .Home,Jdas.Applications.ExtendAg.Base.UI.ashx#8)
>> Problem #2
>> In attempting to incorporate groovy script into our scripts. Groovy  
>> code doesn’t seem to work.
>> Eclipse is our IDE , btw .
>> Is there a simple example of a Canoo webtest script that  
>> incorporates the <groovy> tags with simple groovy code that will  
>> produce some results that I can use to verify that I have  
>> everything working properly (somewhere out on the internet)? The  
>> example on the canoo site didn’t work as is.
>> Im not sure my configuration is correct in Eclipse.I had to  
>> manually add the plugin using a zip file because the software  
>> update feature didn’t work.
>> Can you refer me to any documentation that might get me started
>> Im not even sure this is the right approach. Is Canoo Webtest  
>> commonly used this way or is it better to right groovy scripts that  
>> refer to Canoo webtest commands?
>> Any help would be appreciated.
>
>
> --
> manuel aldana
> aldana@...
> software-engineering blog: http://www.aldana-online.de
>
> _______________________________________________
> WebTest mailing list
> WebTest@...
> http://lists.canoo.com/mailman/listinfo/webtest

--
Ian Homer
mobile ... made simple
http://bemoko.com | http://twitter.com/ianhomer












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

AW: Looking for help running Groovy in Canoo Webtest

by Michael Habbert-4 :: 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 David,

 

1.       about JavaScript – yes it is always a pain …
But htmlunit is extending and supporting more and more JavaScript – all the more we  support the developer with bug-messages

2.       Groovy: you can write Webtests in Goovy – many people do so. Or you can use Groovy Scriptlets insite your XML-Webtest like:

 

<groovy description="execute on blur on comment-element with first.line.id: #{first.line.id}" replaceProperties="true">

      step.context.currentResponse.getHtmlElementById('#{first.line.id}').fireEvent("blur")

</groovy>

Or

<groovy description="select the first element of the new created select-box!" replaceProperties="true" >

step.context.currentResponse.getHtmlElementsByName('target_#{wm_id_1}')[0].options[1].selected=true

</groovy>

 

We do this at the edge of Ant and Webtest. ;-)

 

Yours,

 

Michael

 

 

Von: webtest-admin@... [mailto:webtest-admin@...] Im Auftrag von Zepernick David
Gesendet: Mittwoch, 1. Juli 2009 21:33
An: webtest@...
Betreff: [Webtest] Looking for help running Groovy in Canoo Webtest

 

Hi, my name is David

 

I work for John Deere Agri Services and I am a member of development team that is building business solutions for the agricultural industry.

 

I am , more specifically, a part of the QA group. Not a lot of programming  experience myself but have programmers available to me although their time is limitted.

 

This year our development group decided to give Canoo Webtest a try.

 

I have become familiar with Canoo Webtest and have been able to write automated test scripts.

 

We as a team have had some success but have run into a few problems that have limitted what we can do with Canoo Webtest.

 

I am hoping to get a little direction from someone that has experience with Canoo Webtest.

 

 

 

 

Problem #1

Javascript errors  -  Controls that are incorporated to some of our webpages that are written in javascript cause errors when running the scripts and prevent us from saving pages.

 

 

The error messages look like this:

: TypeError: Cannot find function extend in object function Object()

{ [native code for Object.Object, arity=1] } .

.Home,Jdas.Applications.ExtendAg.Base.UI.ashx#8)

 

Problem #2

In attempting to incorporate groovy script into our scripts. Groovy code doesn’t seem to work.

Eclipse is our IDE , btw .

Is there a simple example of a Canoo webtest script that incorporates the <groovy> tags with simple groovy code that will produce some results that I can use to verify that I have everything working properly (somewhere out on the internet)? The example on the canoo site didn’t work as is.

 

Im not sure my configuration is correct in Eclipse.I had to manually add the plugin using a zip file because the software update feature didn’t work.

 

Can you refer me to any documentation that might get me started

 

Im not even sure this is the right approach. Is Canoo Webtest commonly used this way or is it better to right groovy scripts that refer to Canoo webtest commands?

 

Any help would be appreciated.

 

 
 
Michael Habbert
Key-Work Consulting GmbH | Kriegsstr. 100 | 76133 Karlsruhe | Germany | www.key-work.de
Fon: +49-721-78203-269 | E-Mail: michael.habbert@... | Fax: +49-721-78203-10
 
Key-Work Consulting GmbH, Karlsruhe, HRB 108695, HRG Mannheim
Geschäftsführer: Andreas Stappert, Tobin Wotring


Re: Looking for help running Groovy in Canoo Webtest

by Marc Guillemot :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi David,

> ...  
>  
> Problem #1
> Javascript errors  -  Controls that are incorporated to some of our
> webpages that are written in javascript cause errors when running the
> scripts and prevent us from saving pages.
>  
>  
> The error messages look like this:
> JavaScript error loading page
> _https://eaqa.jdas.deere.com/Base/Home.aspx?tabcode=HOME&bppik=1_
> <https://eaqa.jdas.deere.com/Base/Home.aspx?tabcode=HOME&bppik=1>
> : TypeError: Cannot find function extend in object function Object()
> { [native code for Object.Object, arity=1] } .
> (_https://eaqa.jdas.deere.com/ajaxpro/Jdas.Applications.ExtendAg.Base.UI.Pages_
> .Home,Jdas.Applications.ExtendAg.Base.UI.ashx#8)

as always for JS errors like this one, there are two possibilities:
- the error *exists* using the "real" browser that you simulate with
WebTest. In this case, +1 for WebTest as it allowed you to detect an
error in your application (which you can ignore if you want to)
- the error *doesn't exists* using the "real" browser that you simulate
with WebTest. In this case, -1 for WebTest as it means that simulation
was not so good here as it should be.

If you're in the second case, you can do following:
- upgrade to the latest WebTest build with, when it's compatible, the
latest HtmlUnit snapshot: if you're lucky, your problem has perhaps
already been fixed.
- if not, try to isolate the JS error to open an issue by WebTest or
HtmlUnit. This means provide the smallest amount of HTML & JS code
allowing to reproduce the problem. You really have to do it if you don't
want to face the problem for ever (or until the problem gets fixed
because someone encountered the same issue but was more courageous and
took the time to report it). Most of the time HtmlUnit's team is very
responsive: with a good failure report (and a not too complicated
problem), the problem may be fixed within a couple of hours!
- as long as it is not fixed, you can try to simulate an other browser.
The JS implementations of the different browsers differ and the maturity
of the HtmlUnit's simulation vary too. WebTest simulates IE6 by default,
but you can change it to FF2, FF3 or IE7.
- ignore the JS error and hack a workaround, for instance in Groovy, to
modify the browser content as it should have been done by the JS code.
This may be tricky as it requires to understand what this JS code is
doing. Be sure to have reported the JS problem if you don't want to live
with your hack for ever ;-)

Perhaps should I had such a doc to WebTest's website... ;-)

Cheers,
Marc.
--
Web: http://www.efficient-webtesting.com
Blog: http://mguillem.wordpress.com

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

Re: Looking for help running Groovy in Canoo Webtest

by A Vander :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Zepernick David wrote:
...
In attempting to incorporate groovy script into our scripts. Groovy code doesn't seem to work.
Eclipse is our IDE , btw .
Is there a simple example of a Canoo webtest script that incorporates the <groovy> tags with simple groovy code that will produce some results that I can use to verify that I have everything working properly (somewhere out on the internet)? The example on the canoo site didn't work as is.
...
Here's an example where I used Groovy to compute a suitable date for a registration...

<group description="Register with date = birthdate + 5 year -1 day?">
  <scriptStep description="Compute date between birthdate and birthdate + 5year" language="groovy">
import java.text.SimpleDateFormat
import java.util.Calendar
                     
// get a handle to the properties
def props = step.webtestProperties
                       
// store property in string
def bd = step.getWebtestProperty( 'de.bbp.datenaissance', step.PROPERTY_TYPE_ANT)
                                     
// convert string to Date
def sdf = new SimpleDateFormat('dd/MM/yyyy')
def dt = sdf.parse( bd)
                             
// do Date + 5 years - 1 day
def cal = java.util.Calendar.getInstance()
cal.setTime( dt)
cal.add( Calendar.YEAR, 5)
cal.add( Calendar.DAY_OF_YEAR, -1)
                     
// convert new Date to string
def dd = sdf.format( cal.getTime())
                     
// store new Date as property ( use #{} to acess it from webtest)
props.putAt('date.tooYoung', dd)
  </scriptStep>
  <invoke description="Register with date = birthdate +5 -1d" url="#{currentFlowKey}" method="POST" content="_eventId=saveEtude&nomEtudeCode=${data.etudes.nom.etude.code}...;dateDebut=#{date.tooYoung}&dateFin=" save="mySaveEtude3" />
  <verifyXPath description="Message '${etudes.error.startDate.upper.birthday}' present?" xpath='//form[@id="etudeForm"]//li[@class="errors" and text()="${etudes.error.startDate.upper.birthday}"]' />
</group>

Regards, Avander