--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/ccaovBk7A58J.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/uiiMDpko048J.
>>Anji
<input id="uploader" type="file" />
The "type" attribute is the key here. Most browsers, absent styling, render this as a text box (sometimes disabled), along with a button labeled "Browse" or some such. The correct way to automate this is with the sendKeys() method with the path to the file to be uploaded. Full stop. A call to the click() method is not required.
In some browser drivers, sendKeys() will invoke the native file selection dialog, fill in the file name, and dismiss it; in others it will bypass the native dialog altogether. Either way, the WebDriver is perfectly capable of handling it.
Problems start to arise, however, when website developers start to think that the standard HTML file upload control isn't functional enough, or isn't pretty enough, or whatever other reason they may come up with for trying to reinvent the wheel. In those cases, and only those cases, where the page isn't using an <input> method where the type attribute is set to "file", should you need to explore options outside of WebDriver.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/WU0kO-z7G9wJ.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/WU0kO-z7G9wJ.
Using the GWT/GXT framework does not prevent your developers from using an <input type=”file”> in your page. Suggesting it does is frankly ridiculous.
I agree with Mark.Our devs use "plupload" library as well which means there is NO <input type="file"> and you can not just use "senKeys" method as couple people were trying to tell others in this thread.As I can see "plupload" lib becomes popular among devs probably because its high security. It receives specific params from a particular object (flash, js etc) and then jQuery binding upload action as Mark described above.Many people in this thread recommends to use Autoit or Robot AWT.1. I have used Autoit before and in case when you run your tests on one machine and execute them on another (which is common thing nowadays with CI) this tool becomes totally useless.Plus it works only for Windows so no cross platform testing.2. Use Robot AWT is more flexible way but in case when you have to run your tests remotely you will need to run an additional server on remote machine which is not convenient at all but anyway better than autoit.I would be very appreciated if somebody will share his/her experience of handling such situations.
For uploading files you should be able to just use sendkeys to send the file's full path name to the input element triggering the upload.
Have you tried that?
Subject: [selenium-users] File upload using selenium webdriver in a form...
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/ccaovBk7A58J.
When you click on ‘Choose File’ button, OS native file select dialog will be opened. This dialog will not be recognized by your driver, so when uploading any file you should never click on ‘Choose File’ button. Instead, use sendkeys to select the file,
WebElement El = driver.findElement(By.id("'fileUploadField'"));
El.sendKeys("c:\\temp\\test.txt");
This will select your file without having to select it through file select dialog. This works flawlessly across all supported drivers.
If you are running your test on grid then you should let your remote driver know that the file is residing on local machine and not remote machine. This can be achieved by setting LocalFileDetector for RemoteWebElement,
WebElement El = driver.findElement(By.id("'fileUploadField'"));
((RemoteWebElement) El ).setFileDetector(new LocalFileDetector());
El.sendKeys("c:\\temp\\test.txt");
Here you are setting local file detector for file upload element, so whenever you use sendkeys on this element, your RemoteWebDriver uses this file detector object to detect the file. If the file is detected then it will be base64 encoded and uploaded to remote server through JSON Wire Protocol and the remote fixed path will be selected as a file path.
Please check my blog http://muthutechno.wordpress.com/2014/07/09/uploading-files-in-selenium-webdriver/
On Thursday, September 13, 2012 11:33:26 AM UTC+5:30, webdriver user wrote:
9:11 PM (less than a minute ago) |