I want to automate file compression on " http://pdfcompressor.com/ " website. I used selenium to upload files but failed to do so. Below is the code
file_path = "/home/gugli/Documents/script_py/Dainik_Jagron/h2.pdf"
browser = webdriver.Firefox()
url = 'http://pdfcompressor.com/'
browser.get(url)
I tried inserting in the input tag but got an err
browser.find_element_by_id('html5_1cciqvn90sehe7rachs1c3m03').send_keys(filepath)
this is the snapshot of input tag
following is the err :
Traceback (most recent call last):
File "/home/gugli/Documents/script_py/Dainik_Jagron/uploadfiles.py", line 32, in <module>
browser.find_element_by_id('html5_1cciqvn90sehe7rachs1c3m03').send_keys("/home/gugli/Documents/script_py/Dainik_Jagron/h2.pdf")
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 330, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 832, in find_element
'value': value})['value']
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 297, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException:
Message: Unable to locate element: [id="html5_1cciqvn90sehe7rachs1c3m03"]
The file is stored in a "ul" tag. But failed to upload in this tag even. Here is the snapshot of dom structure for before and after uploading the file
The file uploaded is stored as a "li" element ( image 3 ). I tried inserting in "div id = carousel" container but again it was a failed attempt. How else can I upload file here using python.