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

Categories

I'm using selenium webdriver, C#.

Is it possible to make work webdriver with Firefox select file dialog? Or must I use something like AutoIt?

See Question&Answers more detail:os

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

1 Answer

If you are trying to select a file for upload Selenium 2 supports HTML file inputs. For example:

HTML

<input type="file" id="uploadhere" />

Selenium Code

IWebElement element = driver.FindElement(By.Id("uploadhere"));
element.SendKeys("C:\Some_Folder\MyFile.txt");

Basically you "type" (with SendKeys) the full file path to the file input element. Selenium handles the file selection dialog for you.

However if you want to manipulate an arbitrary file selection dialog, then like Anders said, you have to go outside of Selenium.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...