Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/473.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 获取阴影根树的所有innerhtml_Javascript_Selenium_Tree_Webdriver_Shadow - Fatal编程技术网

Javascript 获取阴影根树的所有innerhtml

Javascript 获取阴影根树的所有innerhtml,javascript,selenium,tree,webdriver,shadow,Javascript,Selenium,Tree,Webdriver,Shadow,目标是收集所有影子根的所有html。甚至当一个影子是一棵树包含几个新的一次。我想收集所有的html。就像使用F12一样,您也可以看到所有源代码。到目前为止,我得到了根: <?php // An example of using php-webdriver. namespace Facebook\WebDriver; use Facebook\WebDriver\Remote\DesiredCapabilities; use Facebook\WebDriver\Remote\Remot

目标是收集所有影子根的所有html。甚至当一个影子是一棵树包含几个新的一次。我想收集所有的html。就像使用F12一样,您也可以看到所有源代码。到目前为止,我得到了根:

<?php
// An example of using php-webdriver.

namespace Facebook\WebDriver;

use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;

require_once('vendor/autoload.php');

$host = 'http://localhost:9515';//chromedriver.exe
$capabilities = DesiredCapabilities::chrome();
$driver = RemoteWebDriver::create($host, $capabilities, 5000);

$driver->get('http://shop.polymer-project.org');

// adding cookie
$driver->manage()->deleteAllCookies();

$cookie = new Cookie('cookie_name', 'cookie_value');
$driver->manage()->addCookie($cookie);

$cookies = $driver->manage()->getCookies();
//print_r($cookies);

$driver->manage()->timeouts()->implicitlyWait(100);
// print the title of the current page
echo "The title is '" . $driver->getTitle() . "'\n";


$driver->executeScript('
var allNodes = document.getElementsByTagName(\'*\');
for (var i = 0; i < allNodes.length; i++) {
  if(allNodes[i].shadowRoot) {
    //alert(\'it works\'+i+allNodes[i].shadowRoot.innerHTML); 
  }
}
');
//$driver->quit();

?>

使用childNodes可以得到树,但不能得到内容。欢迎任何建议!使用childNodes可以生成树,但不能生成内容。欢迎任何建议!