Selenium Grid / Sauce Labs插件/ Ant设置

时间:2013-01-17 10:35:08

标签: ant selenium saucelabs

我正在尝试使用ANT启动Selenium Grid实例。使用此处的响应How can I run Selenium 2 Grid from an Ant build?,我能够使用以下build.xml

成功启动Grid
<project name="selenium-grid" default="launch-hub" basedir=".">
  <property name="selenium.version" value="2.28.0"/>
  <property name="sauce.version" value="1.0.8"/>
  <path id="selenium.classpath">
    <pathelement path="${basedir}/"/>
    <fileset dir="${basedir}/">
      <include name="selenium-server-standalone-${selenium.version}.jar"/>      
      <include name="sauce-grid-plugin-${sauce.version}.jar"/>  
    </fileset>
    <pathelement path="${java.class.path}/"/>
  </path>
  <target name="launch-hub"
          description="Launch Selenium Hub">
    <java classname="org.openqa.grid.selenium.GridLauncher"
          classpathref="selenium.classpath"
          fork="true"
          failonerror="true">       
      <arg value="-role"/>
      <arg value="hub"/>      
    </java>    
  </target>
</project>
ant launch-hub

继续,我想使用Selenium Grid的Sauce Labs Grid插件,可在此处找到:https://github.com/rossrowe/sauce-grid-plugin/wiki 在wiki之后,我可以使用DOS中的以下内容在我的Windows机器上启动这两个

java -cp selenium-server-standalone-2.25.0.jar;sauce-grid-plugin-1.0.7.jar org.openqa.grid.selenium.GridLauncher -role hub -servlets com.saucelabs.grid.SauceOnDemandAdminServlet,com.saucelabs.grid.SauceOnDemandConsoleServlet

现在我想通过将目标“launch-hub”添加到Sauce labs“servlets”的参数中来合并Sauce实验室Servlet(抱歉发布真实代码时很抱歉)

arg value="-servlets"
arg value="com.saucelabs.grid.SauceOnDemandAdminServlet,com.saucelabs.grid.SauceOnDemandConsoleServlet"

我使用

ant launch
重新启动,这里是windows返回的错误:

launch-hub:
     [java] 17 janv. 2013 10:58:40 org.openqa.grid.selenium.GridLauncher main
     [java] INFO: Launching a selenium grid server
     [java] 17 janv. 2013 10:58:50 org.openqa.grid.web.utils.ExtraServletUtil createServlet
     [java] ATTENTION: The specified class : com.saucelabs.grid.SauceOnDemandAdminServlet cannot be instanciated com.sau
celabs.grid.SauceOnDemandAdminServlet
     [java] 17 janv. 2013 10:58:50 org.openqa.grid.web.utils.ExtraServletUtil createServlet
     [java] ATTENTION: The specified class : com.saucelabs.grid.SauceOnDemandConsoleServlet cannot be instanciated com.s
aucelabs.grid.SauceOnDemandConsoleServlet
     [java] 2013-01-17 10:58:50.806:INFO:osjs.Server:jetty-7.x.y-SNAPSHOT
     [java] 2013-01-17 10:58:50.866:INFO:osjsh.ContextHandler:started o.s.j.s.ServletContextHandler{/,null}
     [java] 2013-01-17 10:58:50.876:INFO:osjs.AbstractConnector:Started SocketConnector@0.0.0.0:4444`enter code here

Selenium Grid启动但没有servlet,因此没有Saucelabs访问

有什么想法吗?

更新使用1.0.7的酱汁插件工作了。不能使用版本1.0.8

1 个答案:

答案 0 :(得分:1)

通过使用带有额外参数的build.xml,我能够使用Sauce Grid插件成功运行Grid服务器,例如

<project name="selenium-grid" default="launch-hub" basedir=".">
    <property name="selenium.version" value="2.25.0"/>
    <property name="sauce.version" value="1.0.8"/>
    <path id="selenium.classpath">
        <pathelement path="${basedir}/"/>
        <fileset dir="${basedir}">
            <include name="selenium-server-standalone-${selenium.version}.jar"/>
            <include name="sauce-grid-plugin-${sauce.version}.jar"/>
        </fileset>
        <pathelement path="${java.class.path}/"/>
    </path>
    <target name="launch-hub"
            description="Launch Selenium Hub">
        <java classname="org.openqa.grid.selenium.GridLauncher"
              classpathref="selenium.classpath"
              fork="true"
              failonerror="true">
            <arg value="-servlets"/>
            <arg value="com.saucelabs.grid.SauceOnDemandAdminServlet,com.saucelabs.grid.SauceOnDemandConsoleServlet"/>
            <arg value="-role"/>
            <arg value="hub"/>
        </java>
    </target>
 </project>

从查看Selenium Grid代码时,抛出ClassNotFoundException时会生成构建输出中出现的错误...是否可以检查sauce-grid-plugin jar文件是否位于$ {basedir中}?