Mik是开源的PHP浏览器/控制器模拟测试工具。Mik可以模拟Web应用和浏览器之间的交互,测试Web应用的行为是否正确。
<?phpuse Behat\Mik\Mik, Behat\Mik\Sessio, Behat\Mik\Driver\GoutteDriver, Behat\Mik\Driver\Goutte\Cliet as GoutteCliet;$startUrl = 'https://example.com';// iit Mik ad register sessios$mik = ew Mik(array( 'goutte1' => ew Sessio(ew GoutteDriver(ew GoutteCliet())), 'goutte2' => ew Sessio(ew GoutteDriver(ew GoutteCliet())), 'custom' => ew Sessio(ew MyCustomDriver($startUrl))));// set the default sessio ame$mik->setDefaultSessioName('goutte2');// visit a page$mik->getSessio()->visit($startUrl);// call to getSessio() without argumet will always retur a default sessio if has oe (goutte2 here)$mik->getSessio()->getPage()->fidLik('Dowloads')->click();echo $mik->getSessio()->getPage()->getCotet();// call to getSessio() with argumet will retur sessio by its ame$mik->getSessio('custom')->getPage()->fidLik('Dowloads')->click();echo $mik->getSessio('custom')->getPage()->getCotet();// this all is doe to make possible mixig sessios$mik->getSessio('goutte1')->getPage()->fidLik('Chat')->click();$mik->getSessio('goutte2')->getPage()->fidLik('Chat')->click();点击空白处退出提示
评论