| || |
sendkeys is not working for file upload
I am using firefox version 30.0 with selenium IDE version 2.5.0.
I started the recording for the website http'colon''slash''slash'pdf2jpg'dot'net
Clicked 'Choose a PDF file'. Uploaded a file from my machine.
Clicked 'Convert PDF to JPG'.
Stopped the recording and Exported Testcase as 'Python2 / Unitest / Webdriver'.
In the recorded py file, the contents are like this:
driver = self.driver
driver.get(self.base_url + "/")
When I replayed the script, the file name that I entered did not come again.
In the above code, I edited the send_keys line with
Even then, the file name text box is coming blank, and script is not proceeding after that. Please help me in uploading the file.
Thanks in advance.
Selenium can't handle file dialogs as they are part of the operating system, not the browser.
You would have to do some workaround by making a call to AutoIT or a direct http post/get.
Are you exporting your tests to unittest/webdriver? That syntax looks more like webdriver than selenium ide.
If you're using webdriver, then there's a trick to doing that, however it doesn't work across all browsers when done Remotely.
SauceLabs blog as a nice write up on how to do it. It involves instantiating a file Locator/Detector which serializes the file over selenium's protocol.
Cool trick. Will have to try that next time I encounter that issue.