我是Selenium的新手,正设法把头缠住它。我正在Chrome控制台中尝试几行JS,如果可以运行,请通过executeScript
执行它们。
例如,我在做document.swQuerySelectorAll("[fill]");
在Chrome中,这将返回以下内容:
例如四个4 path
个数组。
在硒中做同样的事情
async getWithFill(){
return this.driver.executeScript("return document.swQuerySelectorAll('[fill]')");
}
...
...
const withfill = await this.getWithFill();
console.log("withfill: " + JSON.stringify(withfill, getCircularReplacer()));
({getCircularReplacer
根据here)
但是,这不会返回n个路径数组,而是一个driver
对象本身:
[{"driver_":{"flow_":{"propagateUnhandledRejections_":true,"activeQueue_":null,"taskQueues_":{},"shutdownTask_":null,"hold_":{"_called":false,"_idleTimeout":2147483647,"_idlePrev":{"_unrefed":false,"msecs":2147483647,"_timer":{}},"_idleStart":40995,"_repeat":2147483647,"_destroyed":false}},"session_":{"stack_":null,"parent_":null,"callbacks_":null,"state_":"fulfilled","handled_":true,"value_":"e4e6a8fe5fda07f3f72c0cbf328ed68d","queue_":{"name_":"TaskQueue::14","tasks_":[],"interrupts_":null,"pending_":null,"subQ_":null,"state_":"finished","unhandledRejections_":{}}},"executor_":{"w3c":false,"customCommands_":{},"log_":{"name_":"webdriver.http.Executor","level_":null,"parent_":{"name_":"webdriver.http","level_":null,"parent_":{"name_":"webdriver","level_":null,"parent_":{"name_":"","level_":{"name_":"OFF","value_":null},"parent_":null,"handlers_":null},"handlers_":null},"handlers_":null},"handlers_":null}},"fileDetector_":null},"id_":{"stack_":null,"parent_":null,"callbacks_":null,"state_":"fulfilled","handled_":false,"value_":"0.5320635799241777-7","queue_":{"name_":"TaskQueue::1680","tasks_":[],"interrupts_":null,"pending_":null,"subQ_":null,"state_":"finished","unhandledRejections_":{}}}},{"id_":{"stack_":null,"parent_":null,"callbacks_":null,"state_":"fulfilled","handled_":false,"value_":"0.5320635799241777-8"}}]
这什至是什么?如何根据Chrome控制台输出按预期返回path
数组?