首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么CodeCeption验收测试不能通过web驱动程序访问网页?

为什么CodeCeption验收测试不能通过web驱动程序访问网页?
EN

Stack Exchange QA用户
提问于 2016-01-19 13:26:54
回答 1查看 1.6K关注 0票数 0

我正在为Joomla构建一个CodeCeption验收测试环境。为了更容易地在任何开发人员的机器上再现测试,我想提供一个基于Docker的环境。

我正在使用docker编写创建环境:

代码语言:javascript
运行
复制
web:
  image: php:5-apache
  volumes:
    - ../..:/var/www/html
  ports:
    - 8080:80
  links:
    - db:db

db:
  image: mysql
  volumes:
    - ../../tests/_envs/sql:/var/lib/mysql
  ports:
    - 3306:3306

hub:
  image: selenium/hub
  ports:
    - 4444:4444

firefox:
  image: selenium/node-firefox-debug
  ports:
    - 5900
  links:
    - hub:hub

CodeCeption设置如下(JoomlaBrowser只是扩展了WebDriver,添加了特定于Joomla的功能):

代码语言:javascript
运行
复制
class_name: AcceptanceTester
modules:
    enabled:
        - JoomlaBrowser:
            url: 'http://localhost:8080/'     # the url that points to the joomla installation at /tests/system/joomla-cms
            browser: 'firefox'
            window_size: 1024x768
            capabilities:
              unexpectedAlertBehaviour: 'accept'
            username: 'admin'
            password: 'admin'
            database host: 'localhost'             # place where the Application is Hosted #server Address
            database user: 'root'                  # MySQL Server user ID, usually root
            database password: '1234'                  # MySQL Server password, usually empty or root
            database name: 'dbname'            # DB Name, at the Server
            database type: 'mysqli'                # type in lowercase one of the options: MySQL\MySQLi\PDO
            database prefix: 'jos_'                # DB Prefix for tables
            install sample data: 'Yes'              # Do you want to Download the Sample Data Along with Joomla Installation, then keep it Yes
            sample data: 'Default English (GB) Sample Data'    # Default Sample Data
            admin email: 'admin@mydomain.com'      # email Id of the Admin
            language: 'English (United Kingdom)'   # Language in which you want the Application to be Installed
            joomla folder: '/home/.../path to Joomla Folder' # Path to Joomla installation where we execute the tests
        - \Helper\Acceptance
error_reporting: E_ALL

一旦启动,web环境就可以通过http://localhost:8080 (按预期重定向到Joomla的新副本上的installation/index.php )进行手动访问。http://localhost:4444/grid/console上的Selenium网格也是如此。然而,在运行CodeCeption验收测试时,测试只会看到“问题加载页”浏览器消息。

我错过了什么?

EN

回答 1

Stack Exchange QA用户

回答已采纳

发布于 2016-01-26 17:56:31

终于自己解决了。

问题是,火狐容器不应该访问localhost,而应该访问web容器。因此,需要一个到该容器的链接。固定的docker-compose.yml文件现在看起来像

代码语言:javascript
运行
复制
web:
  image: php:5-apache
  volumes:
    - .:/var/www/html
  ports:
    - "8080:80"
  links:
    - db:db

db:
  image: mysql
  volumes:
    - tests/_envs/sql:/var/lib/mysql
  environment:
    - MYSQL_ROOT_PASSWORD=root
  ports:
    - "3306:3306"

hub:
  image: selenium/hub
  ports:
    - "4444:4444"

firefox:
  image: selenium/node-firefox-debug
  links:
    - hub:hub
    - web:web
  ports:
    - "5900:5900"
  expose:
    - "5555"

主要的区别是链接到web

验收测试设置必须相应更改:

代码语言:javascript
运行
复制
class_name: AcceptanceTester
modules:
    enabled:
        - JoomlaBrowser:
            url: 'http://web/'     # the url that points to the joomla installation at /tests/system/joomla-cms
            browser: 'firefox'
            window_size: 1024x768
            capabilities:
              unexpectedAlertBehaviour: 'accept'
            username: 'admin'
            password: 'admin'
            database host: 'localhost'             # place where the Application is Hosted #server Address
            database user: 'root'                  # MySQL Server user ID, usually root
            database password: '1234'                  # MySQL Server password, usually empty or root
            database name: 'dbname'            # DB Name, at the Server
            database type: 'mysqli'                # type in lowercase one of the options: MySQL\MySQLi\PDO
            database prefix: 'jos_'                # DB Prefix for tables
            install sample data: 'Yes'              # Do you want to Download the Sample Data Along with Joomla Installation, then keep it Yes
            sample data: 'Default English (GB) Sample Data'    # Default Sample Data
            admin email: 'admin@mydomain.com'      # email Id of the Admin
            language: 'English (United Kingdom)'   # Language in which you want the Application to be Installed
            joomla folder: '/home/.../path to Joomla Folder' # Path to Joomla installation where we execute the tests
        - \Helper\Acceptance
error_reporting: E_ALL

这里的主要更改是将URL指向http:/web/而不是localhost

票数 0
EN
页面原文内容由Stack Exchange QA提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://sqa.stackexchange.com/questions/16558

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档