« Return to Thread: Running selenium

Re: Running selenium

by hdockter :: Rate this Message:

Reply to Author | View in Thread


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


 « Return to Thread: Running selenium