0
WebDriverWait wait = new WebDriverWait(driver,30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("(//a[contains(text(),'Download')])")));   
WebElement download = driver.findElement(By.xpath("(//a[contains(text(),'Download')])"));
download.click();

I am trying to click a download link in a chrome via selenium. It has many other links in the page and those are working but this download link alone causes timeout exception.

And the anchor tag in the page is as follows

<a href="https://www.somexyz.com/key/url?url=http%3A//www.somexyz.net/webform_protected_file/lwhW0167ec9HZBEefQrIoSg6JpnW0zvlQyxL-iaR8Ms/download" target="_other" rel="nofollow">Download file</a>

Any suggestions would be appreciated.

Guy
  • 46,488
  • 10
  • 44
  • 88
bngk
  • 59
  • 14

1 Answers1

0
driver.switchTo().frame("msg_body");
                WebDriverWait wait = new WebDriverWait(driver,30);
                wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("(//a[contains(text(),'Download')])")));   
                WebElement download = driver.findElement(By.xpath("(//a[contains(text(),'Download')])")); 
                download.click();

The above code worked for me with first switching the driver to the iframe that is intended and then selecting the link worked.

bngk
  • 59
  • 14