Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
324 views
in Technique[技术] by (71.8m points)

How to handle a window file upload pop up in selenium c#

I have a file upload scenario where i need to enter the file name. Its a windows based file upload pop up. Send keys or window handles wont work as selenium does not recognize it. Other than using Auto IT is there any other way enter image description here

enter image description here

When an image is uploaded the following tag will be generated [![enter image description here][3]][3]

question from:https://stackoverflow.com/questions/65929809/how-to-handle-a-window-file-upload-pop-up-in-selenium-c-sharp

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This has been answered a few times on here but here is what you need to do. Find the input for the file upload and use send keys to the file path. You do not interact with the ui file upload dialog box.

ex:

        string filePath = "c:Filesfile.png";
        driver.FindElement(By.XPath("//input[@type='file']")).SendKeys(filePath);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...