I present below two ways to upload a . The first uses Python Selenium in a special case (invisible input), the second handles a Windows Dialog Box.

Invisible input

If the input is hidden, make it visible. Here is an example (Python).
The input is hidden at the bottom of the page and looks like this:

<input type="file" multiple="multiple" class="dz-hidden-input" style="visibility: hidden; position: absolute; top: 0px; left: 0px; height: 0px; width: 0px;">

Now let’s see how to send the file (note the use of an absolute path):

file_input = driver.find_element_by_xpath("//input[@class = 'dz-hidden-input']")
# make the input visible:
driver.execute_script('arguments[0].style = ""; arguments[0].style.display = "block"; arguments[0].style.visibility = "visible";', file_input)
# send file:

(cf This SO answer)

Interact with Windows file upload dialog (Windows and Python only)

You can directly handle the Windows dialog box using the Pywinauto module (the window has to be visible, not hidden).

import pywinauto

def (Name_of_File):
    app = pywinauto.application.Application()
    mainWindow = app['Envoi du fichier'] # main windows' title
    ctrlBis = mainWindow['Ouvrir'] # open file button

""" example:

Windows’ titles are inside square brackets. You can easily get them (and other windows’ attributes) using tools like SWAPY.

Source link https://sqa.stackexchange.com/questions/34848/some-files-path-in-excel-sheet-that-path-need-to-pass-in-file-upload-text-and-c


Please enter your comment!
Please enter your name here