As you lot know, File uploading Is really difficult In selenium webdriver because It Is non able to handgrip file uploading dialog. So nosotros volition purpose AutoIT with selenium webdriver to upload file In spider web applications. We convey already created AutoIt script (Script To Upload File.exe) In previous transportation service which can select file from File Upload dialog. We volition larn how to Integrate that AutoIt script alongside selenium webdriver In this section.
In java, It Is really tardily to execute whatever executable file. We tin piece of job whatever executable script file using Runtime.getRuntime().exec("File Path") method. We volition purpose this coffee method In our selenium webdriver exam script to handgrip file upload dialog.
So at 1 time in conclusion selenium webdriver alongside AutoIt Integration exam script Is equally bellow.
Note : "Script To Upload File.exe" in addition to "Test.txt" files should live on located at "E:\\AutoIT" folder.
Note : "Script To Upload File.exe" in addition to "Test.txt" files should live on located at "E:\\AutoIT" folder.
package AutoIt; import java.io.IOException; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; world course of written report AutoIt_Test { WebDriver driver; @BeforeTest world void setup() throws Exception { driver =new FirefoxDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get(" "); } @Test world void testCaseOne_Test_One() throws IOException, InterruptedException { //Click on browse button. driver.findElement(By.name("img")).click(); //To execute autoIt script .exe file which Is located at E:\\AutoIT\\ location. Runtime.getRuntime().exec("E:\\AutoIT\\Script To Upload File.exe"); } }
Run to a higher house script In eclipse.
- It volition click on browser push clitoris to opened upwards File Upload dialog using selenium webdriver.
- Then Runtime.getRuntime().exec("E:\\AutoIT\\Script To Upload File.exe"); syntax volition execute AutoIt generated "Script To Upload File.exe" file. It volition choose file in addition to click on opened upwards push clitoris of File Upload dialog.
On completion of script, you lot volition encounter that Test.txt file Is uploaded equally shown In bellow given Image.
This agency nosotros tin upload file using AutoIt In selenium webdriver.
Read side past times side transportation service to know how to download file using AutoIT + Selenium webdriver.
This agency nosotros tin upload file using AutoIt In selenium webdriver.
Read side past times side transportation service to know how to download file using AutoIT + Selenium webdriver.