我正在尝试在 Google Drive 中自动上传文件功能。
用于传递参数的元素被隐藏,高度为 0px。
任何用户操作都不会使该元素可见。因此,我需要解决方法以在不可见时单击该元素。
<input type="file" style="height: 0px; visibility: hidden; position: absolute; width: 340px; font-size: inherit;" multiple=""/>
上述元素的 xpath 是 -
//*[@class='goog-menu goog-menu-vertical uploadmenu density-tiny']/input
我在用
WebDriver.findElement(By.xpath(<xpath>).sendKeys(<uploadFile>)
例外 -
org.openqa.selenium.ElementNotVisibleException
- 元素当前不可见,因此可能无法与之交互。
我尝试过使用 JavascriptExecutor。但无法找到确切的语法。