google-chrome-devtools,Java,Selenium,Google Chrome Devtools,Web Inspector,Chrome Devtools Protocol,Selenium Webdriver,google Chrome Devtools" /> google-chrome-devtools,Java,Selenium,Google Chrome Devtools,Web Inspector,Chrome Devtools Protocol,Selenium Webdriver,google Chrome Devtools" />

Selenium WebDriver(java)能否与浏览器交互;检查刀具元件选择器?

Selenium WebDriver(java)能否与浏览器交互;检查刀具元件选择器?,java,selenium,google-chrome-devtools,web-inspector,chrome-devtools-protocol,selenium-webdriver,google-chrome-devtools,Java,Selenium,Google Chrome Devtools,Web Inspector,Chrome Devtools Protocol,Selenium Webdriver,google Chrome Devtools,通过使用selenium,我可以访问位于inspect选项卡中的浏览器元素选择器(浏览器中的Ctrl+Shift+C)吗 我想使用该选择器“指向”一个元素,并使其在浏览器中高亮显示 例如,一些简单的东西,如: WebElement elem=driver.findElement(By.id(“用户名”); 元素指针() 这将在浏览器中显示高亮显示/选中的元素,与“检查”选项卡“工作”相同 部分是。使用,您很快就能使用Java客户端与API交互 集成仍在WIP(Work in Progress)中

通过使用selenium,我可以访问位于inspect选项卡中的浏览器元素选择器(浏览器中的Ctrl+Shift+C)吗

我想使用该选择器“指向”一个元素,并使其在浏览器中高亮显示

例如,一些简单的东西,如:

WebElement elem=driver.findElement(By.id(“用户名”);
元素指针()


这将在浏览器中显示高亮显示/选中的元素,与“检查”选项卡“工作”相同

部分。使用,您很快就能使用Java客户端与API交互

集成仍在WIP(Work in Progress)中,@AdiOhana最近为和域提供了一个更好的面向用户的API

在讨论中,@AdiOhana提到示例用法如下:

    driver.getDevTools().createSession();
    driver.getDevTools().send(new Command("Profiler.enable", ImmutableMap.of()));
    driver.getDevTools().send(new Command("Profiler.start", ImmutableMap.of()));
    //register to profiler events
    driver.getDevTools().addListener(new Event("Profiler.consoleProfileStarted", ConsoleProfileStarted.class), new Consumer<Object>() {
        @Override
        public void accept(Object o) {
            //do something
        }
    });
driver.getDevTools().createSession();
send(新命令(“Profiler.enable”,ImmutableMap.of());
send(新命令(“Profiler.start”,ImmutableMap.of());
//注册到探查器事件
driver.getDevTools().addListener(新事件(“Profiler.consoleProfileStarted”、consoleProfileStarted.class)、新使用者(){
@凌驾
公共无效接受(对象o){
//做点什么
}
});
注意:在将探查器域添加到Selenium java客户端之前,您必须提供映射器


奥特罗

这不太可能,因为驱动程序通常无法访问特定于浏览器的操作/UI。你可以在元素中注入CSS来做一些事情,比如在元素周围加一个红色边框,等等。谷歌“selenium highlight element”,你会发现很多例子,比如据我所知,chrome的驱动程序中没有提供这样的api