kentaro-a/headless-testing-for-cakephp

使用Selenium为CakePHP3应用程序进行无头浏览器测试

dev-master 2018-08-23 07:24 UTC

This package is not auto-updated.

Last update: 2024-10-02 20:41:55 UTC


README

使用Selenium为CakePHP3应用程序进行无头浏览器测试。这使用了Facebook Webdriver和Selenium Standalone Server。

安装

$ composer require kentaro-a/headless-testing-for-cakephp

您必须获取google-chrome。

$ curl https://intoli.com/install-google-chrome.sh | bash

您想使用的驱动程序。
例如)如果您使用ChromeDriver,您应该从这里获取其二进制文件。
https://sites.google.com/a/chromium.org/chromedriver/downloads

用法

作为守护进程启动Selenium Standalone Server。

$ vendor/se/selenium-server-standalone/bin/selenium-server-standalone -port 60002 -log "/tmp/selenium.log" > /dev/null 2>&1 &

测试

在测试之前,您必须在tests/TestCase中编写测试代码。有关测试代码的更多信息,您可以查看示例。像以下那样执行cakephp3测试。

$ vendor/bin/phpunit tests/TestCase/HeadlessSampleTest.php --filter test001

提示

  • 确保进程
$ ps aux|grep -e selenium -e chrome
  • 如果无法终止进程,您应该尝试“强制”使用“kill -9 process”。
$ pkill -f chrome ; pkill -f selenium
  • 如果无法创建驱动程序,请确保您的端口没有被僵尸进程占用。
$ lsof -i:60002
  • Xpath提示 Chrome插件 ChroPath 是获取特定元素xpath的最简单方法。