gpt4 book ai didi

java - anchor 标记不可点击

转载 作者:行者123 更新时间:2023-12-01 18:35:15 26 4
gpt4 key购买 nike

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();

我正在尝试通过 selenium 单击 chrome 中的下载链接。它在页面中有许多其他链接,并且这些链接都有效,但仅此下载链接就会导致 timeout exception .

页面中的 anchor 标记如下

<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>

如有任何建议,我们将不胜感激。

最佳答案

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();

上面的代码对我有用,首先将驱动程序切换到预期的 iframe,然后选择有效的链接。

关于java - anchor 标记不可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60073277/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com