Python Selenium - How to upload image in this case? -


here html page:

<li data-picture-status="off">     <p class="picture-uploader-add">adicionar</p>     <div class="picture-uploader-controls">         <a role="button" class="ch-close ch-hide" href="#"><span class="ch-hide">excluir</span></a>     </div>     <p class="picture-uploader-principal">foto principal</p> </li> <div class="picture-uploader-controls">     <a role="button" class="ch-close ch-hide" href="#"><span class="ch-hide">excluir</span></a> </div> 

here python code:

driver = webdriver.chrome() driver.maximize_window() time.sleep(10) driver.find_element_by_xpath('//p[@class="picture-uploader add"]').send_keys('c:/image.jpg') 

here error: selenium.common.exceptions.webdriverexception: message: unknown error: cannot focus element

it seem you're trying handle wrong element... try handle <input type="file"> instead:

driver.find_element_by_xpath('//input[@type="file"]').send_keys('c:/image.jpg') 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -