Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHPUnit&;硒_Php_Selenium_Selenium Webdriver_Phpunit - Fatal编程技术网

PHPUnit&;硒

PHPUnit&;硒,php,selenium,selenium-webdriver,phpunit,Php,Selenium,Selenium Webdriver,Phpunit,我有两个问题: 我已经在PHPUnit和Selenium中创建了很多测试用例,但我希望将它们作为一个组运行,而不是一次运行一个测试用例 在多个浏览器上运行它们的最佳方式是什么。我已经寻找了使用webdriver的例子,但不确定如何使用 我的两个测试用例是: 第一: } 第二: 您可以看看 拉动请求 如果所有测试都位于同一个目录中,那么请尝试使用目录名而不是文件名调用phpunit。Phpunit将在给定目录中查找*Test.php 2) 从setUp()函数中删除setHost()、setPor

我有两个问题:

  • 我已经在PHPUnit和Selenium中创建了很多测试用例,但我希望将它们作为一个组运行,而不是一次运行一个测试用例
  • 在多个浏览器上运行它们的最佳方式是什么。我已经寻找了使用webdriver的例子,但不确定如何使用
  • 我的两个测试用例是:

    第一: }

    第二: 您可以看看 拉动请求 如果所有测试都位于同一个目录中,那么请尝试使用目录名而不是文件名调用phpunit。Phpunit将在给定目录中查找*Test.php

    2) 从setUp()函数中删除setHost()、setPort()和setBrowser(),改为在静态属性中声明浏览器。下面将在每个声明的浏览器中运行每个测试

    public static $browsers = [
        [
            'host' => 'localhost',
            'port' => 4444,
            'browserName' => 'firefox'
        ],
        [
            'host' => 'localhost',
            'port' => 4444,
            'browserName' => 'chrome'
        ]
    ];
    

        class AdminUserViewReqTabOptions extends PHPUnit_Extensions_Selenium2TestCase{
           public function setUp()
           {
               $this->setHost('localhost'); // Set the hostname for the connection to the Selenium server.
               $this->setPort(4444); // set port # for connection to selenium server
               $this->setBrowser('firefox'); // set the browser to be used
               $this->setBrowserUrl('http://www.example.com');  // set base URL for tests
           }
    
           public function testDisplayServer()
                 $this->url('index.php'); // Set the URL to test
                 // check for the existence of the strin 'All Open'
                 $this->assertRegExp( '/Server: Development/i', $this->source() );        
              }
           }
    
    public static $browsers = [
        [
            'host' => 'localhost',
            'port' => 4444,
            'browserName' => 'firefox'
        ],
        [
            'host' => 'localhost',
            'port' => 4444,
            'browserName' => 'chrome'
        ]
    ];