我试图点击一个“图像”,但该图像被归类为“图像报告”或“报告”。HTML代码乱七八糟:
<report _ngcontent-ifc-c23="" class="dash-inner fill-parent ng-star-inserted dashlet-small-horiz dashlet-small-vert" ng-responsive="" _nghost-ifc-c28="" style="margin-top: 0rem;">
<image-report _ngcontent-ifc-c28="" _nghost-ifc-c39="" class="ng-star-inserted">
<img _ngcontent-ifc-c39="" class="fill-parent" tabindex="-1" src="/SMIWeb/rest/v1/contents/image?imagePath=%2Fshared%2FImages%2FBTN-TaskDetails_ON.png" alt="Image" style="touch-action: none; user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);">
</image-report>
</report>我尝试过以下几种方法:
remDr$findElement(using="xpath", value="//img[@src='/SMIWeb/rest/v1/contents/image?imagePath=%2Fshared%2FImages%2FBTN-TaskDetails_ON.png']")
remDr$findElement(using="xpath", value="//report[@class='dash-inner.fill-parent.ng-star-inserted.dashlet-small-horiz dashlet-small-vert']")
remDr$findElement(using="xpath", value="//img-report[@class='ng-star-inserted']")
remDr$findElement(using="xpath", value="//img[@class='ng-star-inserted']")
remDr$findElement(using="xpath", value="//img[@class='fill-parent']")如何调用"report“或"image-report”类型的标记名?任何编程语言的答案都会很有帮助(例如,常规的Selenium)。
发布于 2021-10-01 04:48:27
问题最终是我想要点击的图像位于一个框架中。
我使用以下命令访问框架:
webElem <- remDr$findElements("css", "iframe")
remDr$switchToFrame(webElem[[1]])一旦我切换到框架中,我就能够使用第一行代码访问图像:
details <- remDr$findElement(using="xpath", value="//img[@src='/SMIWeb/rest/v1/contents/image?imagePath=%2Fshared%2FImages%2FBTN-TaskDetails_OFF.png']")
details$clickElement()此外,"image-report“和"report”都是自定义元素。
发布于 2021-10-01 11:48:17
你可以试一试
"//img[@class='fill-parent']/.."使用此路径,您将获得img元素的父元素
当然,如果您的图像报告是唯一的,您可以通过以下命令找到它:
//image-report[@class='ng-star-inserted']https://stackoverflow.com/questions/69400164
复制相似问题