【发布时间】:2015-01-21 14:13:04
【问题描述】:
为了避免上传文件的窗口对话框,我正在尝试以下操作:
driver.findElement(By.xpath("//span[@class='ab-attachment-item']/input")).sendKeys(filePath);
以下是HTML代码sn-p:
<div class="ab-attachments">
<span class="ab-attachment-item" ng-hide="isReadOnly()" style="background-color: transparent;">
<input class="ab-attachment-input ng-isolate-scope firefinder-match" type="file" rx-file-upload="file" accept=".pdf,image/*" style="background-color: transparent;">
但它会导致错误:
org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
我想确认这个错误是否是因为span标签中的ng-hide="isReadOnly()"?
以及如何使用 Selenium WebDriver 本身(使用 JavaScriptExecutor 或其他东西)解决这个问题?
为了处理这个对话框,可以使用 Sikuli、AutoIt 等其他工具;但我想避免这种开销。
【问题讨论】:
标签: java javascript angularjs selenium selenium-webdriver