[python-win32] Controlling IE file input boxes
Paul_S_Johnson at mnb.uscourts.gov
Paul_S_Johnson at mnb.uscourts.gov
Mon Aug 16 19:46:28 CEST 2004
We are testing a web site we are developing by controlling IE through
Python and need to be able to input the value of an INPUT tag where
TYPE=FILE. I understand the security concern of MS not allowing this, but
isn't there some way around it? The python code below initiates the
windows file dialog (what happens when someone clicks the "browse" button
of the file input box). Is there anyway to script through this and input
a file name?
===============================
HTML:
<html>
<head>
<title>My Site</title>
</head>
<body>
<form name="myform" action="" method="post">
<input type="file" name="file_1" value="Pick Me"><br>
</form>
</body>
</html>
===============================
Python code:
from win32com.client import DispatchEx
ie = DispatchEx('InternetExplorer.Application')
ie.Navigate("file://C:/myhtml.html")
ie.Visible = 1
myfilebox = ie.Document.forms[0].elements.all["file_1"]
myfilebox.click()
#??? now what???
================================
Paul Johnson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20040816/e8155d03/attachment.htm
More information about the Python-win32
mailing list