Reputation: 1
I am doing a selenium automation in python and I encountered a problem.
To upload a file I need the input tag but it only activates when I click over a "Upload" button, this same button opens a sepparate window that can't be managed through selenium (or at least the ways I've tried). When I close()
the driver they remain open.
I need to upload several files, but this window locks the interaction with the navigator, so the driver stops working.
Perhaps some way to activate input field withour opening the tab.
This is the window
I've tried usking keys to alt F4 the window
I've tried closing al with .close()
I've tried not to click the button so the windows doesn't open but the input tag is not there unless I click.
Upvotes: 0
Views: 132
Reputation: 87
This is an idea, it worked for me with a single file, maybe it will work for you or inspire you with new ideas. Try this: First, you need your path.
home_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
Second, you need the path of your image and name. Lets say for example a list like this:
file_details = ["dir_name", "file_name.jpg"]
Then, you write a func:
def upload_file(self, file_name):
self.find_element(*LOCATOR_OF_INPUT).send_keys(file_name)
And last, you call this func:
upload_file(os.path.join(home_path, os.path.join(*file_details)))
Basically, you do not click the input, you are "sending" a file to the input instead.
Best of luck, hope it helps you.
Upvotes: 1