Reputation: 11
I used Selenium to execute a bunch of actions within a browser (tried both Chrome and FireFox) with a Mac.
I used a Selenium function to click a button that opens an OS level dialog box where I can select and "open" a file. I know Selenium can't interact with dialog boxes, but is there a Python function that can? Tkinter
seems to only be able to operate within dialog boxes that it opens and not with already open boxes.
This is a version of the code and the last Selenium function that made the dialog box open is bolded:
import webbrowser
from from selenium import webdriver
element = webdriver.Chrome()
element.get('http://www.somewebsite.com')
uploadfunction = driver.find_element_by_id('upload_file').click()
I'm adamant to do this purely through Python (via command line) before resorting to another language.
Upvotes: 1
Views: 3325
Reputation: 1007
import win32gui
win32gui.FindWindow(ClassName,WindowName) #should give you the control of the dialog that you want.
plus look at the accepted answer to this question for a (albeit kind of messy) helper for dialogs.
If you're still stuck let me know.
Upvotes: 1