简体   繁体   English

使用Selenium Webdriver PHP关闭测试

[英]Close a test using Selenium Webdriver PHP

Here's how I write my tests: 这是我编写测试的方式:

A class with private methods and a single public method which runs all my others private methods. 一个带有私有方法和一个可以运行我所有其他私有方法的公共方法的类。

class MyTest extends PHPUnit_Framework_TestCase
{
    private function firstScenario() {
        $this->navigation = new Navigation($this->webDriver);
        $this->navigation->goToPointA();
        //...
    }

    private function secondScenario() {
        $this->navigation = new Navigation($this->webDriver);
        $this->navigation->goToPointA();
        //...
    }

    public function testRun() {
        //...
        $this->firstScenario();
        $this->secondScenario();
        //...
    }

I have in other classes some generic methods, whose one named Navigation.php. 在其他类中,我有一些通用方法,其中一个名为Navigation.php。 In this class, I have all my methods which enable me to go to a specific point of my application. 在本课程中,我拥有所有使我能够转到应用程序特定点的方法。

All I want to do is, according to a condition, to close (or quit, or dispose, or whatever you want) my test, properly, without returning an error. 根据条件,我要做的只是正确地关闭(或退出,处置或任何您想要的)测试,而不会返回错误。 I tried quit(), close() and dispose() but maybe I use its wrong. 我尝试过quit(),close()和dispose(),但也许我用错了。

You should probably add quit() to your tear down. 您可能应该将quit()添加到您的拆卸清单中。 Depending on how you are invoking driver it would be something like: 根据您调用driver ,可能是这样的:

protected function tearDown() {
   if ($this->driver) {
      $this->driver->quit();
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM