下载了webdriver后,每次调用的时候,都会弹出一个chrome的界面,而且处理完后还不会自动关闭(当然可能是因为我的姿势问题),所以看了一下facebook 的webdriver,嗯配合chromedriver,很多事情就都解决了!

上一段测试代码:

$options = DesiredCapabilities::chrome();

$chrome = new ChromeOptions();
$chrome->addArguments(['--headless']);
$options->setCapability(ChromeOptions::CAPABILITY,$chrome );


$driver = RemoteWebDriver::create('http://localhost:9515', $options);
$driver->get('http://www.baidu.com');
$result = $driver->findElement(WebDriverBy::id('wrapper'))
->getText();
echo $result;

还确实是比较方便。我要测试一下时间。然后和phantomjs做一下对比。我想应该不会太慢吧