如何使用 selenium webdriver 通过窗口提示从本地上传文件?
How to upload files from local via window prompt using selenium webdriver?
我想执行以下操作:
我使用了以下三种不同的方式在 selenium webdriver 中上传文件.
I have used below three different ways to upload a file in selenium webdriver.
例如:<input type="file" name="uploadsubmit">下面是简单的代码:
WebElement element = driver.findElement(By.name("uploadsubmit"));
element.sendKeys("D:/file.txt");
driver.findElement(By.name("uploadSubmit"));
String validateText = driver.findElement(By.id("message")).getText();
Assert.assertEquals("File uploaded successfully", validateText);
第二种情况是使用Robot类上传,该类用于(生成本机系统输入事件)控制鼠标和键盘.
Second case is uploading using Robot class which is used to (generate native system input events) take the control of mouse and keyboard.
另一种选择是使用AutoIt"(开源工具).
The the other option is to use 'AutoIt' (open source tool).
您可以找到以上三个示例:- 使用 Selenium Webdriver 上传文件
You can find the above three examples : - File Uploads with Selenium Webdriver
这篇关于使用 selenium 上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何在 JTextPane 中的组件周围环绕文本?How to wrap text around components in a JTextPane?(如何在 JTextPane 中的组件周围环绕文本?)
MyBatis,如何获取插入的自动生成密钥?[MySql]MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何获取插入的自动生成密钥?[MySql])
在 Java 中插入 Oracle 嵌套表Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java:如何将 CLOB 插入 oracle 数据库Java: How to insert CLOB into oracle database(Java:如何将 CLOB 插入 oracle 数据库)
为什么 Spring-data-jdbc 不保存我的 Car 对象?Why does Spring-data-jdbc not save my Car object?(为什么 Spring-data-jdbc 不保存我的 Car 对象?)
使用线程逐块处理文件Use threading to process file chunk by chunk(使用线程逐块处理文件)