As we all know, Selenium will not support window based elements. To upload/download we need to use some third party tools.
Below post explains how to upload a file from local drive using AutoIt.
Below post explains how to upload a file from local drive using AutoIt.
- Dowload AutoIt from link : http://www.autoitscript.com/site/autoit/downloads/
- Install it
- Below is the sample code to upload :
(This code is to select a file from window after clicking on
browse button from web page, After this we have click on upload button from web
page)
WinWaitActive("File
Upload")
Send("C:\Temp\Test.txt")
Send("{ENTER}")
Write this code in Notepad and save the file as “Upload.au3”
Right Clicked on the created file “Upload.au3” and click on
Compile Script.
You will get “Upload.exe” file
Call
this file in Selenium script or in RFT script as below:
Process proc = Runtime.getRuntime().exec("C:\\Temp\\ Upload.exe");
Sample Selenium Code
using AutoIt upload:
public class Upload {
public WebDriver driver;
@Before
public void setUp() throws Exception {
driver= new FirefoxDriver();
driver.manage().window().maximize();
}
@Test
public void testTestScenario1() throws Exception
{
driver.get("http://www.2shared.com/");
driver.findElement(By.id("upField")).click();
Thread.sleep(5000);
Process proc = Runtime.getRuntime().exec("C:\\Temp\\Upload.exe");
driver.findElement(By.xpath("//input[@title='Upload file']")).click();
}
@After
public void tearDown() throws Exception {
driver.quit();
}
}
Really help this post.. Thanks Madhu..
ReplyDeleteBut the above code works only for Firefox browser.. Not able to upload the file in
chrome and IE browsers.
How to upload the file in chrome and IE browsers using AutoIt.
This comment has been removed by the author.
ReplyDeleteHi Madhu,
ReplyDeleteThanks a lot for posting this code for file attachment.Finally after many attempts my script got executed..Thanks once again !
can we upload file to hp quality centeR?
ReplyDeleteGreat article, thanks for sharing a helpful information.
ReplyDeleteBeen looking for this functionality.
Selenium training in Chennai | Best Selenium training institute in Chennai
Please keep sharing such articles.
lebron 18
ReplyDeletecalvin klein outlet
off white
a bathing ape
curry shoes
hermes birkin
kyrie 7 shoes
supreme clothing
supreme clothing
golden goose sneakers
Your information about Software is really interesting. Also I want to know the latest new techniques which are implemented in testing. Please update it in your website. readymade salwar suit wholesale , wholesale salwar suit ,
ReplyDeletenext page i9c66f1k03 buy replica bags replica radley bags find out here now j8z92a4f90 replica louis vuitton bags replica bags chicago h0m58y0k25 replica bags on amazon Visit This Link w0i37r6w35 replica bags in china
ReplyDelete