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

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -