Selenium 2 (WebDriver) and Phpunit?

后端 未结 11 1220
我在风中等你
我在风中等你 2020-12-23 12:01

Any one know how to use Selenium 2 with Phpunit? Are there any Selenium 2 samples in PHP?

11条回答
  •  佛祖请我去吃肉
    2020-12-23 12:08

    I recommened the usage of Menta, a Selenium 2 Framework which requires WebDriver. Both packages are PSR-0 compatible, so you can use them with Composer. You can configure selenium with the phpunit.xml. Here an example

    
        
            
            
            
            
            
            
        
        
            
                tests/integration
            
        
        
            
        
    
    

    The bootstrap file reads the configuration variables from testing.selenium.*, so you can easily set new variables.

    getValue('testing.selenium.seleniumServerUrl'),
        $configuration->getValue('testing.selenium.browser')
    );
    

    Now you can easily implement you testcases. Here an example

    open('http://www.google.de');
            $element = $session->element(LocatorStrategy::NAME, 'q');
            $this->assertTrue($element->displayed());
        }
    }
    

    The Menta Package also have two demo files, located here

提交回复
热议问题