centOS,Jenkins,Firefox& Selenium GRID - UnableToCreateProfileException

时间:2013-06-19 18:38:04

标签: firefox selenium jenkins centos selenium-webdriver

我们让Jenkins在centOS vm上运行无头,并通过另一台计算机上的http调用访问它。

我有一个运行UI Selenium Tests的项目,除了firefox之外,一切运行良好。它抱怨该配置文件没有在centOS vm上,所以它可以将它转发到Windows VM进行测试。有没有人知道如何在centOS上获得最新最好的firefox,因为yum只有17个(无头CentOS VM)?另外,如果我只想在该VM上scp当前的firefox配置文件,那么firefox配置文件存储在CentOS操作系统中的哪个位置?我还没有想到的任何其他解决方案?如果需要更多信息,请告诉我,jenkins错误如下:

org.openqa.selenium.firefox.UnableToCreateProfileException: Given model profile directory does not exist: C:\Users\Selenium\FirefoxDriver Build info: version: '2.31.0', revision: '1bd294d', time: '2013-02-27 20:52:59' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-358.6.1.el6.x86_64', java.version: '1.7.0' Driver info: driver.version: unknown org.openqa.selenium.firefox.FirefoxProfile.verifyModel(FirefoxProfile.java:154) org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:92) org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:79) com.igt.sqes.automation.selenium.factories.WebDriverFactory.createWebDriver(Unknown Source) com.igt.sqes.automation.arcus.setup.ArcusTestSuiteSetup.setUp(Unknown Source) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:601) org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80) org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564) org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213) org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138) org.testng.SuiteRunner.privateRun(SuiteRunner.java:277) org.testng.SuiteRunner.run(SuiteRunner.java:240) org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) org.testng.TestNG.runSuitesSequentially(TestNG.java:1198) org.testng.TestNG.runSuitesSequentially(TestNG.java:1194) org.testng.TestNG.runSuitesLocally(TestNG.java:1123) org.testng.TestNG.run(TestNG.java:1031) org.testng.TestNG.privateMain(TestNG.java:1338) org.testng.TestNG.main(TestNG.java:1307)

从Windows框运行时它可以正常工作,因为驱动程序位于该位置并可以转发以测试vm。

2 个答案:

答案 0 :(得分:2)

<强> 1。尝试安装较新版本的Firefox

为此,您可以使用Remi存储库

## Remi Dependency on CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

## CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

Step by step instruction

<强> 2。尝试复制现有配置文件并明确指定

请参阅以下主题:CentOS Selenium - Preparing firefox profile

答案 1 :(得分:0)

使CentOS VM可用的Firefox配置文件在运行Selnium节点的Windows VM上使用的一种方法是在Windows上创建指向Firefox配置文件的共享,然后在CentOS上安装该共享。以下是我用来完成这项工作的步骤:

  1. 在Windows上,创建Firefox配置文件所在目录的共享。默认的Firefox配置文件通常位于C:\ Users \ username \ AppData \ Local \ Mozilla \ Firefox \ Profiles \ 427nha20.default中。您可能希望将配置文件放在权限受限的目录中,例如具有只读权限的目录。
  2. 在CentOS上,使用您为Windows共享命名的名称在/ mnt目录中创建一个目录。名称不必相同,但有助于保持一致。
  3. 在CentOS上,将以下行添加到/ etc / fstab文件中: // windowsVMIP / windowsShareName / mnt / windowsShareName cifs username = windowsUser,password = windowsPassword,uid = 123,gid = 123,_ netdev,ro 0 0
  4. windowsVMIP是具有共享的VM的IP; windowsShareName是Windows共享的名称; / mnt / windowsShareName是您为Windows共享提供的名称;用户名和密码是Windows用户的凭据; uid是CentOS上的用户ID; gid是CentOS上的主要组ID(你可以通过执行grep jenkins / etc / passwd来获取uid和gid。它们分别是第3和第4个属性);
  5. 在CentOS中,通过执行以下操作手动挂载Windows共享:mount -t cifs -o username = windowsUser,password = windowsPassword,uid = 123,gid = 123 // windowsVMIP / windowsShareName / mnt / windowsShareName
  6. cd to / mnt / windowsShare和ls以确保安装成功
  7. 通过将FirefoxDriver.PROFILE功能设置为指向CentOS安装的共享来配置Selenium Firefox驱动程序。然后在创建时将功能传递给Selenium Webdriver。例如在Java中:

    FirefoxProfile profile = new FirefoxProfile(new File("/mnt/windowsShareName")); DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability(FirefoxDriver.PROFILE, profile);
    WebDriver driver = new RemoteWebDriver(new URL(gridHubURL), capabilities);

  8. Firefox配置文件将来自CentOS共享,并在实例化Selenium驱动程序后转发到Windows VM Selenium节点。