« Return to Thread: Looking for help running Groovy in Canoo Webtest

Re: Looking for help running Groovy in Canoo Webtest

by Ian Homer :: Rate this Message:

Reply to Author | View in Thread

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

 « Return to Thread: Looking for help running Groovy in Canoo Webtest