php selenium 服务端,一个 PHP Selenium 客户端

PHP Selenium client

Selenium is a great tool for testing. This package gives you a boilerplate setup to automate UI testing tasks you'd do manually otherwise.

For example: you can make a scenario to test the flow of a form in one of your projects, without having to worry about setting up Selenium itself. This package uses Chrome by default, but you're able to override it with whatever driver you want.

Support us

Learn how to create a package like this one, by watching our premium video course:

f5a7e6def3c8cda25268f7b20310a1b9.png

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

git clone git@github.com:spatie/selenium-client.git

Usage

You can add your own scenarios in the Scenarios folder.

Next, you'll need to start the Selenium server like so:

php client.php serve

Next you can run your scenarios like so:

php client.php execute dummy [--wait]

Adding the --wait option will keep the browser open until you manually stop it.

Making scenarios

Scenario classes should extend Spatie\Selenium\Scenario. There are a few helper methods provided like $this->element($selector) and $this->click($selector); but you can also directly access the Selenium driver via $this->driver.

For more information about the Selenium driver, please visit this repository.

A simple scenario can look like this.

class MyScenario extends Scenario

{

public function __construct()

{

// The website to visit.

parent::__construct('https://mywebsite.com.test');

}

public function run()

{

// Go to a page

$this->get('/contact');

$this->element('input[name=name]')->sendKeys('Brent');

$this->element('input[name=email]')->sendKeys('brent@spatie.be');

$this->element('input[name=message']->sendKeys('Test');

$this->submit('form#contact');

}

}

Scenarios can be run with the execute command, in this case you'd run execute my.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.

Postcardware

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

We publish all received postcards on our company website.

Credits

License

The MIT License (MIT). Please see License File for more information.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值