- jeevitha
- Posts : 1
Join date : 2014-06-27
sendkeys is not working for file upload
Fri Jun 27, 2014 8:45 pm
Hi,
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:
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.
Jeevitha.
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:
- Code:
def test_pdf(self):
driver = self.driver
driver.get(self.base_url + "/")
driver.find_element_by_id("advanced_pdf_file").click()
driver.find_element_by_id("html5_18rendrprhrsv8nonqc521tal3").clear()
driver.find_element_by_id("html5_18rendrprhrsv8nonqc521tal3").send_keys("")
driver.find_element_by_id("convert_pdf_to_jpg_button").click()
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
- Code:
driver.find_element_by_id("html5_18rendrprhrsv8nonqc521tal3").send_keys("C:\\pdfurl-guide.pdf")
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.
Jeevitha.
- mail2prassadAmateur
- Posts : 41
Join date : 2013-06-05
Re: sendkeys is not working for file upload
Fri Jul 18, 2014 7:43 pm
It looks like the IDs are generated dynalically ('html5_18rendrprhrsv8nonqc521tal3' - not a general static id). This might be the reason the filename is appearing blank.
Try reloading the page couple of times and see whether the ID remains same.
Try reloading the page couple of times and see whether the ID remains same.
- nabhanya.varmaActive particpant
- Posts : 13
Join date : 2014-03-02
Re: sendkeys is not working for file upload
Sat Sep 13, 2014 5:37 pm
If not with the dynamic ID, please check if that has a tag 'input' and is enabled.
It is mandatory that sendKeys() works only when the textbox is enabled. So please make sure that the input element is visible.
If not then we need to go for other third party tools which interacts with the OS controls.
http://www.seleniumeasy.com/selenium-tutorials/uploading-file-with-sendkeys-method
It is mandatory that sendKeys() works only when the textbox is enabled. So please make sure that the input element is visible.
If not then we need to go for other third party tools which interacts with the OS controls.
http://www.seleniumeasy.com/selenium-tutorials/uploading-file-with-sendkeys-method
Permissions in this forum:
You cannot reply to topics in this forum