【发布时间】:2019-01-21 16:53:36
【问题描述】:
我正在尝试通过 Google Chrome 中的 Selenium 单击记录按钮。但是我做不到。未找到元素。我尝试过使用 id 和 xpath。他们都没有工作。
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>
任何线索将不胜感激。
【问题讨论】:
-
请分享相关html代码
-
您将不得不分享更多代码:这是在框架内吗?这是在 shadow-DOM 中吗?有很多 AJAX 吗?
-
我不确定 AJAX 或 shadow-DOM。但是,您可以通过在 Google Chrome 中打开“chrome://tracing”作为 url 轻松找到它
-
使用 shadow-DOM。看到这个:stackoverflow.com/q/48286398/3124333
-
谢谢你.. 它有效。
标签: google-chrome selenium shadow-dom