I
I
Ivan Yakushenko2019-07-10 16:01:07
Python
Ivan Yakushenko, 2019-07-10 16:01:07

How to pass image through file select window in Selenium?

The page has the following image submission form:
5d25e05b4295b109600295.jpeg

<ol class="bp" id="u_0_0">
    <li class="bq"><input type="file" name="pic"></li>
    <li>
        <input value="Save" type="submit" class="br bs bt bu bv">
    </li>
</ol>

Manually when I select an image to send in the forms, nothing appears and in general nothing changes on the entire page. Reviewed all requests in Chrome > Inspect > Network also did not find anything where the link to my image would be transferred.
Tried to send image like this:
driver.find_element(By.XPATH, '//input[@type="file"][@name]').send_keys(img)

Mistake:
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: File not found : /libs/img/42.jpg

The file is in the folder.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Eremin, 2019-07-10
@kshnkvn

Try, first, to specify the full path (from the root) to the
/libs/img/42.jpg file - is the libs folder in the root of the file system?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question