Running selenium

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

Running selenium

by cressie176 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm writing a noddy web app to evaluate whether I can use gradle on future java/groovy projects. So far I can start up jetty and run the app, but am struggling to launch selenium. Our existing build system has (among others) a RunSelenium.groovy script which I'd like to reuse. With a lot of functionality removed the script boils down to something like this...
task runSelenium << {
   File report = new File('test/selenium/report/suite.html')
   File suite = new File('test/selenium/selenese/suite.html')
   
   def server = new org.openqa.selenium.server.SeleniumServer()
   server.start()
    
    def launcher = new org.openqa.selenium.server.htmlrunner.HTMLLauncher(server)
    if (launcher.runHTMLSuite('*firefox', 'http://localhost:8080/blah', suite, report, 10000, false) == 'PASSED') {
        println "YIP!"
    }	
}
The problem I'm getting is that org.openqa.selenium.server.SeleniumServer is not on the classpath. I added it via settings.gradle
mavenRepo urls: ['http://archiva.openqa.org/repository/snapshots/']
dependencies 'org.openqa.selenium.server:selenium-server:1.0-SNAPSHOT'
but this resulted in
Execution failed for task ':runSelenium'.
Cause: sealing violation: can't seal package org.mortbay.util: already loaded
which I'm guessing is some class loading conflict between gradle and selenium. I've seen posts explaining how to do this using ant.java, but we've got a lot of custom functionality in our existing build scripts and I'd like to re-use them if possible.

Re: Running selenium

by hdockter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jun 8, 2009, at 12:24 AM, cressie176 wrote:

> I'm writing a noddy web app to evaluate whether I can use gradle on  
> future java/groovy projects. So far I can start up jetty and run the  
> app, but am struggling to launch selenium. Our existing build system  
> has (among others) a RunSelenium.groovy script which I'd like to  
> reuse. With a lot of functionality removed the script boils down to  
> something like this...
> task runSelenium << {
>    File report = new File('test/selenium/report/suite.html')
>    File suite = new File('test/selenium/selenese/suite.html')
>
>    def server = new org.openqa.selenium.server.SeleniumServer()
>    server.start()
>
>     def launcher = new  
> org.openqa.selenium.server.htmlrunner.HTMLLauncher(server)
>     if (launcher.runHTMLSuite('*firefox', 'http://localhost:8080/ 
> blah', suite, report, 10000, false) == 'PASSED') {
>         println "YIP!"
>     }
> }
> The problem I'm getting is that  
> org.openqa.selenium.server.SeleniumServer is not on the classpath. I  
> added it via settings.gradle
> mavenRepo urls: ['http://archiva.openqa.org/repository/snapshots/']
> dependencies 'org.openqa.selenium.server:selenium-server:1.0-SNAPSHOT'
> but this resulted in
> Execution failed for task ':runSelenium'.
> Cause: sealing violation: can't seal package org.mortbay.util:  
> already loaded
> which I'm guessing is some class loading conflict between gradle and  
> selenium. I've seen posts explaining how to do this using ant.java,  
> but we've got a lot of custom functionality in our existing build  
> scripts and I'd like to re-use them if possible.

Can you show us your dependencies declaration for getting selenium  
into the build script classpath?

- Hans

--
Hans Dockter
Gradle Project Manager
http://www.gradle.org


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Running selenium

by cressie176 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hdockter wrote:
Can you show us your dependencies declaration for getting selenium  
into the build script classpath?
I added the dependency into settings.gradle as follows...

mavenRepo urls: ['http://archiva.openqa.org/repository/snapshots/']
dependencies 'org.openqa.selenium.server:selenium-server:1.0-SNAPSHOT'



Re: Running selenium

by hdockter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jun 9, 2009, at 1:09 PM, cressie176 wrote:

>
>
> hdockter wrote:
>>
>> Can you show us your dependencies declaration for getting selenium
>> into the build script classpath?
>>
>
> I added the dependency into settings.gradle as follows...
>
> mavenRepo urls: ['http://archiva.openqa.org/repository/snapshots/']
> dependencies 'org.openqa.selenium.server:selenium-server:1.0-SNAPSHOT'

There is a conflict between the Jetty that is shipped with Gradle and  
used by the Jetty plugin and the Jetty needed by Selenium. It is one  
of our top priorities to implement proper classpath isolation between  
plugins and between a plugin and a build script. But right now they  
all share one classpath. As you need both the Jetty plugin and  
selenium this is hard to solve. One thing you could try is to exclude  
Jetty from the selenium dependencies. But as Selenium uses Jetty 5 and  
the Gradle comes with Jetty 6 this is likely to fail. Another option  
would be to exclude just the jetty-util jar. But again chances are  
high that things won't work.

For example:

dependency 'org.openqa.selenium.server:selenium-server:1.0-SNAPSHOT' {
        exclude module: 'jetty-util'
}

- Hans

--
Hans Dockter
Gradle Project Manager
http://www.gradle.org




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Running selenium

by cressie176 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


hdockter wrote:
On Jun 9, 2009, at 1:09 PM, cressie176 wrote:

>
>
> hdockter wrote:
>>
>> Can you show us your dependencies declaration for getting selenium
>> into the build script classpath?
>>
>
> I added the dependency into settings.gradle as follows...
>
> mavenRepo urls: ['http://archiva.openqa.org/repository/snapshots/']
> dependencies 'org.openqa.selenium.server:selenium-server:1.0-SNAPSHOT'

There is a conflict between the Jetty that is shipped with Gradle and  
used by the Jetty plugin and the Jetty needed by Selenium. It is one  
of our top priorities to implement proper classpath isolation between  
plugins and between a plugin and a build script. But right now they  
all share one classpath. As you need both the Jetty plugin and  
selenium this is hard to solve. One thing you could try is to exclude  
Jetty from the selenium dependencies. But as Selenium uses Jetty 5 and  
the Gradle comes with Jetty 6 this is likely to fail. Another option  
would be to exclude just the jetty-util jar. But again chances are  
high that things won't work.

For example:

dependency 'org.openqa.selenium.server:selenium-server:1.0-SNAPSHOT' {
        exclude module: 'jetty-util'
}

- Hans

--
Hans Dockter
Gradle Project Manager
http://www.gradle.org




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Thanks anyway Hans.

Re: Running selenium

by hdockter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jun 9, 2009, at 3:22 PM, cressie176 wrote:

>
>
>
> hdockter wrote:
>>
>>
>> On Jun 9, 2009, at 1:09 PM, cressie176 wrote:
>>
>>>
>>>
>>> hdockter wrote:
>>>>
>>>> Can you show us your dependencies declaration for getting selenium
>>>> into the build script classpath?
>>>>
>>>
>>> I added the dependency into settings.gradle as follows...
>>>
>>> mavenRepo urls: ['http://archiva.openqa.org/repository/snapshots/']
>>> dependencies 'org.openqa.selenium.server:selenium-server:1.0-
>>> SNAPSHOT'
>>
>> There is a conflict between the Jetty that is shipped with Gradle and
>> used by the Jetty plugin and the Jetty needed by Selenium. It is one
>> of our top priorities to implement proper classpath isolation between
>> plugins and between a plugin and a build script. But right now they
>> all share one classpath. As you need both the Jetty plugin and
>> selenium this is hard to solve. One thing you could try is to exclude
>> Jetty from the selenium dependencies. But as Selenium uses Jetty 5  
>> and
>> the Gradle comes with Jetty 6 this is likely to fail. Another option
>> would be to exclude just the jetty-util jar. But again chances are
>> high that things won't work.
>>
>> For example:
>>
>> dependency 'org.openqa.selenium.server:selenium-server:1.0-
>> SNAPSHOT' {
>> exclude module: 'jetty-util'
>> }
>>
>> - Hans

What you also could do is something like:

configurations {
     selenium
}

dependencies {
     selenium ...
}

task runSellenium << {
        URL[] classpath = dependencies.resolveClasspath('selenium').collect  
{File file ->  file.toURL()}
         new GroovyShell(new URLClassLoader(classpath,  
Thread.currentThread().contextClassLoader),  new Binding(project:  
project)).evaluate('''
        File report = new File(project.buildDir, 'test/selenium/report/
suite.html')
         File suite = new File(project.buildDir, 'test/selenium/
selenese/suite.html')
         def server = new org.openqa.selenium.server.SeleniumServer()
         server.start() def launcher = new  
org.openqa.selenium.server.htmlrunner.HTMLLauncher(server)
         if (launcher.runHTMLSuite('*firefox', 'http://localhost:8080/blah' 
, suite, report, 10000, false) == 'PASSED') { println "YIP!" }
''')}
}

I haven't tried this particular snippet but the general approach  
should work.

- Hans

--
Hans Dockter
Gradle Project Manager
http://www.gradle.org


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email