1

Here is the 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 is my 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 is the error: selenium.common.exceptions.WebDriverException: Message: unknown error: cannot focus element

1 Answer 1

1

It seem that you're trying to handle wrong element... Try to handle <input type="file"> instead:

driver.find_element_by_xpath('//input[@type="file"]').send_keys('C:/image.jpg')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.