相关疑难解决方法(0)

Selenium Webdriver - 单击隐藏的元素

我正在尝试在Google云端硬盘中自动上传文件功能.

用于传递参数的元素隐藏为height - 0px.

任何用户操作都不会使此元素可见.所以我需要一个工作来点击元素不可见.

<input type="file" style="height: 0px; visibility: hidden; position: absolute; width: 340px; font-size: inherit;" multiple=""/>
Run Code Online (Sandbox Code Playgroud)

上述元素的xpath是 -

//*[@class='goog-menu goog-menu-vertical uploadmenu density-tiny']/input
Run Code Online (Sandbox Code Playgroud)

我在用

WebDriver.findElement(By.xpath(<xpath>).sendKeys(<uploadFile>)
Run Code Online (Sandbox Code Playgroud)

例外 -

org.openqa.selenium.ElementNotVisibleException
Run Code Online (Sandbox Code Playgroud)
  • 元素当前不可见,因此可能无法与之交互.

我尝试过使用JavascriptExecutor.但无法找到确切的语法.

selenium webdriver hidden-field

20
推荐指数
2
解决办法
6万
查看次数

标签 统计

hidden-field ×1

selenium ×1

webdriver ×1