在不同的机器上使用Selenium JAR和WebDriver运行Codeception测试



我正在尝试使用Codeception 1.8和Selenium为有点遗留的PHP和JavaScript应用程序设置一个新的测试结构。如果有人不知道Codeception (http://codeception.com/),它有一些运行测试的选项,其中包括一个内置的PHP浏览器,但基本上是PHPUnit的增强版本。它有运行单元、功能和验收测试套件。

我按照"快速入门"(http://codeception.com/quickstart)中的说明操作,然后,PHP浏览器成功地运行了一个超级简单的验收测试。我遇到的问题是,当我试图改变配置这些测试运行方式的YAML文件时,我想停止使用PHPBrowser,并切换到Selenium,这样我就可以编写涉及DOM和JS的端到端样式测试。

起初,我有问题让chromedriver工作-我从来没有做过,实际上,我不能升级我的Codeception版本,因为我正在使用的代码库在PHP版本:5.3.29中很难设置。然而,我发现这里有一个单独的服务器安装了PhantomJS。

这是很重要的,因为我没有访问sudo安装在我运行selenium JAR的机器上(fileserver 1),也没有安装PhantomJS的机器(webserver 1)。所以我不能安装firefox驱动程序或其他webdriver我自己。

我的问题是:有没有一种方法来运行我的Selenium测试使用WebDriver,而它托管在另一台机器上?是否有一种方法可以在远程机器上使用WebDriver让Selenium运行,或者WebDriver和Selenium JAR必须在同一台机器上?

作为一个额外的注意,两个服务器都在同一个主域上——它们是fileserver1.domain.comwebserver1.domain.com(显然都是假的url)。

这里是我的YAML配置文件为我的codeception设置:

codeception main YAML

paths:
    tests: tests
    log: tests/_log
    data: tests/_data
    helpers: tests/_helpers
settings:
    bootstrap: _bootstrap.php
    suite_class: PHPUnit_Framework_TestSuite
    colors: true
    memory_limit: 1024M
    log: true
modules:
    config:
        Db:
            dsn: ''
            user: ''
            password: ''
            dump: tests/_data/dump.sql

验收测试YAML

# Codeception Test Suite Configuration
    class_name: WebGuy
    modules:
        enabled:
            # - PhpBrowser
            # - Selenium2
            - WebDriver
            - WebHelper
        config:
            WebDriver:
                url: 'https://.../login_logout.php?superuser'
                browser: chrome
                window_size: 1024x768
            # PhpBrowser:
                # url: 'https://.../login_logout.php?superuser'

任何帮助都非常感谢!

是否尝试设置主机和端口参数?
https://github.com/Codeception/Codeception/blob/1.8/docs/modules/WebDriver.md

host - Selenium server host (127.0.0.1 by default) port - Selenium server port (4444 by default)

是否有一种方法来运行我的Selenium测试使用WebDriver,而它托管在另一台机器上?

<我>我认为codeception不能这样做,硒服务器必须在您的主机中运行,我在使用Vagrant之前也有同样的问题,硒必须在您的主机中运行,以便在运行codeception时,您会注意到弹出窗口,如Chrome或Firefox我认为…只要确保您的主机是基于GUI的,能够运行Firefox等浏览器

是否有一种方法可以在远程机器上使用WebDriver让Selenium运行,或者WebDriver和Selenium JAR必须在同一台机器上?

<我>您可以在基于GUI的服务器上运行selenium服务器(jar)。然后按下codeception命令成为事件。


在使用WebDriver/Selenium推送之前,您应该先运行PhpBrowser,直到基于网络的Selenium侦听器。

尝试使用最新版本的2.1,我真的有很多问题与旧版本,如表单操作,也跑出硒之前。

最新更新