通过 Selenium 单击 about:tracing 处的记录按钮
Click Record Button at about:tracing through Selenium
我正在尝试通过 Google Chrome 中的 Selenium 单击“记录”按钮。但是我做不到。未找到元素。我试过使用 id 和 xpath。 None 他们工作了。
WebElement record = driver.findElement(By.id("record-button"));
record.click();
HTML代码是
<template id="profiling-view-template">
<tr-ui-b-info-bar-group></tr-ui-b-info-bar-group>
<x-timeline-view-buttons>
<button id="record-button">Record</button>
<button id="save-button">Save</button>
<button id="load-button">Load</button>
</x-timeline-view-buttons>
<tr-ui-timeline-view>
<track-view-container id="track_view_container"></track-view-container>
</tr-ui-timeline-view>
</template>
如有线索,我们将不胜感激。
我可以通过这个访问那个对象
WebElement root1 = driver.findElement(By.tagName("tr-ui-timeline-view"));
WebElement shadowRoot1 = expandRootElement(root1);
WebElement record1 = shadowRoot1.findElement(By.id("record-button"));
record1.click();
public WebElement expandRootElement(WebElement element) {
WebElement ele = (WebElement) ((JavascriptExecutor) driver).executeScript("return arguments[0].shadowRoot",
element);
return ele;
}
我正在尝试通过 Google Chrome 中的 Selenium 单击“记录”按钮。但是我做不到。未找到元素。我试过使用 id 和 xpath。 None 他们工作了。
WebElement record = driver.findElement(By.id("record-button"));
record.click();
HTML代码是
<template id="profiling-view-template">
<tr-ui-b-info-bar-group></tr-ui-b-info-bar-group>
<x-timeline-view-buttons>
<button id="record-button">Record</button>
<button id="save-button">Save</button>
<button id="load-button">Load</button>
</x-timeline-view-buttons>
<tr-ui-timeline-view>
<track-view-container id="track_view_container"></track-view-container>
</tr-ui-timeline-view>
</template>
如有线索,我们将不胜感激。
我可以通过这个访问那个对象
WebElement root1 = driver.findElement(By.tagName("tr-ui-timeline-view"));
WebElement shadowRoot1 = expandRootElement(root1);
WebElement record1 = shadowRoot1.findElement(By.id("record-button"));
record1.click();
public WebElement expandRootElement(WebElement element) {
WebElement ele = (WebElement) ((JavascriptExecutor) driver).executeScript("return arguments[0].shadowRoot",
element);
return ele;
}