📜  如何在 selenium 中上传 - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:09.552000             🧑  作者: Mango

代码示例1
In order to upload file using selenium we need to locate the upload button 
in the DOM html. Then we do sendKeys by passing the path to the file. 

First, I locate the element which takes the path of the file(Choose file button) :
      WebElement input = driver.findElement(“id”); 
 And then I provide the path to the file using the sendKeys method :
      input.sendKeys(“/path/to/file” + Keys.ENTER);