I am automating a page, where i want to right click a element and then click "Save link as.... I am able to right click on the element but not able to select any option. Below is the code I have written, but instead of selecting a option it actually clicks on that element.
WebElement elementq =driver.findElement(By.xpath("//a[contains(text(),'fedev.docs-gmail.JPG')][@class]"));
Actions builderq = new Actions(driver);
builderq.contextClick(elementq).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER);
builderq.build().perform();
Below is the HTML:
<p><a class="icon icon-attachment" href="/attachments/download/15535/fedev.docs-gmail.JPG">fedev.docs-gmail.JPG</a>
<span class="size">(100 KB)</span>
<a data-confirm="Are you sure?" class="delete" title="Delete" rel="nofollow" data-method="delete" href="/attachments/15535"><img src="/images/delete.png" alt="Delete"></a>
<span class="author">Asim Sarfraz, 25 September 2018 08:24 AM</span>
</p>