【问题标题】:centOS, Jenkins, Firefox & Selenium GRID -- UnableToCreateProfileExceptioncentOS、Jenkins、Firefox 和 Selenium GRID -- UnableToCreateProfileException
【发布时间】:2013-06-19 18:38:04
【问题描述】:

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

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

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。

【问题讨论】:

    标签: firefox selenium jenkins centos selenium-webdriver


    【解决方案1】:

    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

    【讨论】:

    • 我会尽快看的!
    【解决方案2】:

    让 CentOS 虚拟机可以在运行 Selnium 节点的 Windows 虚拟机上使用 Firefox 配置文件的一种方法是在 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 是共享虚拟机的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 到 /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 节点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-25
      相关资源
      最近更新 更多