I'm trying to click on an "image" but that image is classified as an "image report" or a "report". HTML code is messy:
<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=/shared/Images/BTN-TaskDetails_ON.png" alt="Image" style="touch-action: none; user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);">
</image-report>
</report>
I've tried the following:
remDr$findElement(using="xpath", value="//img[@src='/SMIWeb/rest/v1/contents/image?imagePath=/shared/Images/BTN-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']")
How do you call an tagname of type "report" or "image-report"? Answers in any programming language would be helpful (e.g., regular Selenium).
CodePudding user response:
The problem ended up being that the image that I wanted to click on was located in a frame.
I accessed the frame using:
webElem <- remDr$findElements("css", "iframe")
remDr$switchToFrame(webElem[[1]])
Once I switched into the frame, I was able to access the image using the first line of code:
details <- remDr$findElement(using="xpath", value="//img[@src='/SMIWeb/rest/v1/contents/image?imagePath=/shared/Images/BTN-TaskDetails_OFF.png']")
details$clickElement()
CodePudding user response:
Try this one, see if it works for you.
remDr$findElement(using="xpath", value="//image-report[@class='fill-parent']/img")
remDr$findElement(using="xpath", value="//image-report[@class='fill-parent']/img[@class='class='fill-parent']")