Reputation: 87
I'm new with selenium vba and I'm trying to click on a download button, this button is inside a kind of pdf iFrame:
Here is some HTML:
<cr-icon-button id="download" iron-icon="cr:file-download" aria-label="Fazer o download" title="Fazer o download" aria-haspopup="false" aria-disabled="false" role="button" tabindex="0"></cr-icon-button>
and here is what I tryed so far:
1 : ChromoLink.FindElement(By.linktext("Fazer o Download")).Click
2 : ChromoLink.FindElementByLinkText("Fazer o Download").Click
3 :ChromoLink.FindElementsByCss("input")(1).Click
4: ChromoLink.FindElementByClass("toolbarButton download hiddenMediumView").Click
5: ChromoLink.FindElementById("download").Click
6: ChromoLink.FindElementByXPath("/html/body/pdf-viewer//viewer-toolbar//div/div[3]/viewer-download-controls//cr-icon-button//div/iron-icon").Click
7: ChromoLink.FindElementByXPath("/html/body/pdf-viewer//viewer-toolbar//div/div[3]/viewer-download-controls//cr-icon-button//div/iron-icon").ClickAndHold
8: ChromoLink.FindElementByXPath("/html/body/pdf-viewer//viewer-toolbar//div/div[3]/viewer-download-controls//cr-icon-button//div/iron-icon").Click
9: ChromoLink.FindElementByXPath("//*[@id=""download""]").ClickAndHold
10: ChromoLink.FindElementByCss("[title='baixar']").Click
None of those worked
I know that print it's not a good idea, but I'm not able to just copy the whole html:
Upvotes: 1
Views: 1392
Reputation: 193058
To click() on the element first you have to switch to the iframe and you can use either of the following Locator Strategies:
FindElementsByCss:
ChromoLink.SwitchToFrame "iFrameReport"
ChromoLink.FindElementByCss("cr-icon-button#download[title='Fazer o download'][aria-label='Fazer o download']").Click
FindElementByXPath relative to Claims:
ChromoLink.SwitchToFrame "iFrameReport"
ChromoLink.FindElementByXPath("//cr-icon-button[@id='download' and @title='Fazer o download'][@aria-label='Fazer o download']").Click
Upvotes: 1