facebook/php-webdriver은 셀레늄과 PHP를위한 멋진 클라이언트입니다.
웹 작업 (OP가 원하는대로)을 자동화하거나 php-webdriver를 테스트 프레임 워크에 통합 할 수 있습니다.
모두에게
다운로드를 설치하고 facebook/php-webdriver를 설치합니다. composer require facebook/webdriver
Download Selenium & 시작하십시오. java -jar selenium-server-standalone-#.jar
Download Quick Java 프로젝트 디렉토리에 배치하십시오.
이 예에서 사용
, 우리는 javascript
및 cookies
를 제외하고 모든 것을 해제하는 확장 quickjava
를 사용합니다. 여기
더보기 기본 설정 :
https://github.com/ThatOneGuyDotNet/QuickJava/blob/master/defaults/preferences/defaults.js
더보기 예를 여기 명령은 :
https://github.com/facebook/php-webdriver/wiki/Example-command-reference
use Facebook\WebDriver\Firefox\FirefoxProfile;
use Facebook\WebDriver\Firefox\FirefoxDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
// Change this to the path of you xpi
$extensionPath = $this->container->getParameter('kernel.root_dir').'/../bin/selenium/quickjava-2.0.6-fx.xpi';
// Build our firefox profile
$profile = new FirefoxProfile();
$profile->addExtension($extensionPath);
$profile->setPreference('thatoneguydotnet.QuickJava.curVersion', '2.0.6.1');
$profile->setPreference('thatoneguydotnet.QuickJava.startupStatus.Images', 2);
$profile->setPreference('thatoneguydotnet.QuickJava.startupStatus.AnimatedImage', 2);
$profile->setPreference('thatoneguydotnet.QuickJava.startupStatus.CSS', 2);
//$profile->setPreference('thatoneguydotnet.QuickJava.startupStatus.Cookies', 2);
$profile->setPreference('thatoneguydotnet.QuickJava.startupStatus.Flash', 2);
$profile->setPreference('thatoneguydotnet.QuickJava.startupStatus.Java', 2);
//$profile->setPreference('thatoneguydotnet.QuickJava.startupStatus.JavaScript', 2);
$profile->setPreference("thatoneguydotnet.QuickJava.startupStatus.Silverlight", 2);
// Create DC + Driver
$dc = DesiredCapabilities::firefox();
$dc->setCapability(FirefoxDriver::PROFILE, $profile);
$driver = RemoteWebDriver::create($host, $dc);
$driver->get('http://stackoverflow.com');
// Do stuff - https://github.com/facebook/php-webdriver/wiki/Example-command-reference
//$driver->findElement(WebDriverBy::id("element-id"));
// The HTML Source code
$html = $driver->getPageSource();
// Firefox should be open and you can see no images or css was loaded
[php-webdriver] (https://github.com/facebook/php-webdriver) 라이브러리만으로도 충분하며 [Steward] (https://github.com)와 같은 도구를 사용하면 설정이 훨씬 쉬워집니다./lmc-eu/steward). Selenium IDE로 시간을 낭비하지 말고 PHP에서 원하는 시나리오를 작성하는 것이 좋습니다. –