Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

sendkeys is not working for file upload

View previous topic View next topic Go down

sendkeys is not working for file upload

Post by jeevitha on 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:

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.

jeevitha

Posts : 1
Join date : 2014-06-27

Back to top Go down

Re: sendkeys is not working for file upload

Post by mail2prassad on 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.

mail2prassad
Amateur
Amateur

Posts : 41
Join date : 2013-06-05

Back to top Go down

Re: sendkeys is not working for file upload

Post by nabhanya.varma on 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

nabhanya.varma
Active particpant
Active particpant

Posts : 13
Join date : 2014-03-02

Back to top Go down

Re: sendkeys is not working for file upload

Post by Sponsored content Today at 5:02 am


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum