dongyi6543 2015-09-04 21:11
浏览 48

在单独的计算机上使用Selenium JAR和WebDriver运行代码测试

I'm trying to set up a new testing structure for a somehwat-legacy PHP and JavaScript application using Codeception 1.8 and Selenium. In case anyone doesn't know Codeception (http://codeception.com/), it has a few options for running tests which include a built in PHP browser, but basically is an enhanced version of PHPUnit. It has suites for running unit, functional and acceptance tests.

I followed the instructions in the "Quick Start" (http://codeception.com/quickstart), and hurray, the PHP Browser successfully ran a super simple acceptance test. The issue I'm having is when I try to change the YAML file which configured how these tests are run - I want to stop using the PHPBrowser, and switch to Selenium so I can write end to end style tests involving the DOM and JS.

At first, I had issues getting the chromedriver to work - I never did, actually, and I cannot upgrade my Codeception version because the code base I'm working with is hard set in PHP Version: 5.3.29. However, I found out that a separate server here has PhantomJS installed.

This is significant because I don't have access to sudo install on either the machine I run the selenium JAR on (fileserver 1), nor the machine with PhantomJS installed (webserver 1). So I can't install the firefox driver or another webdriver myself.

My question is: Is there a way to run my Selenium tests using the WebDriver while it's hosted on another machine? Is there a way to use a WebDriver on a remote machine to let Selenium run, or do the WebDriver and Selenium JAR have to be on the same machine?

As one more additional note, both of the servers are on the same primary domain -- they are fileserver1.domain.com and webserver1.domain.com (both fake URLs, obviously).

Here are my YAML config files for my codeception setup:

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

acceptance tests 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'

Any help is greatly appreciated!

  • 写回答

2条回答 默认 最新

  • doutong2132 2015-09-05 05:19
    关注

    Is there a way to run my Selenium tests using the WebDriver while it's hosted on another machine?

    I think codeception can't do that, Selenium server must be running in your hosts, I have the same issue before when using Vagrant, the selenium must be running in your hosts so that when running codeception, you will notice a popped-up window such as Chrome or Firefox I think... Just make sure your hosts is a GUI based that could be able to run browsers pref. Firefox

    Is there a way to use a WebDriver on a remote machine to let Selenium run, or do the WebDriver and Selenium JAR have to be on the same machine?

    You can run your selenium server (jar) on your GUI based server. Then push codeception command to become an event.


    You should run first the PhpBrowser before pushing through using WebDriver / Selenium and up until a network based selenium listener.

    Try to use the latest version the 2.1, I really have lots of issues with the old versions such as form manipulations and also running out Selenium before.

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100