EN RU

Upload files with Selenium (Windows version)

Tip

In case when you have basic HTML input for file it’s very easy, just run .find_element_by_id('id_photo').send_keys(<full path to file>). But very often we don’t have such inputs or they are hidden and we cann’t send keys to them. For such cases with using Windows we can do it with help of pywinauto or other automation GUI utilities.

So, if you have open file dialog and run test on windows, I have solution. With help of pywinauto we can put path to file into dialog and click "Open". To connect pywinauto to browser we should have process id, for Firefox we already have right id in driver instance but if you use Chrome, driver has only pid of browser but you need pid of tab, in my example I have only one tab and in code I just get first child of browser. Also we should do few tries to fill out dialog or run some sleep to wait for dialog will be opened.

Next you can found simple example how to upload file.

read full ⇝

    2016-08-08 10:00:20      test selenium