我正在自动化一个页面,我想右键单击一个元素,然后单击“将链接另存为...。我可以右键单击该元素,但无法选择任何选项。下面是我编写的代码,但它实际上不是选择一个选项,而是点击该元素。
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();
下面是 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>
一只甜甜圈
慕尼黑的夜晚无繁华
冉冉说
相关分类