mannu singh
mannu singh

Reputation: 889

How to automate firefox with powershell?

I am currently doing the automation with power shell and I am stuck in the following problem , I have automated internet explorer with scripting in power shell,

But now i need to automate Firefox using this , i have searched and not able to track down , Is there any way or is it possible to automate FF with power shell ....suggestions are required.

Upvotes: 0

Views: 11123

Answers (1)

icnivad
icnivad

Reputation: 2291

Have a look at http://watin.org/ You can work with the watin.dll wich supports multiple browsers..

I started to use it because i needed a File Upload which comobject InternetExplorer.Application can't do...

Little snippet to get you started:

$watin     = [Reflection.Assembly]::LoadFrom( "c:\WatiN.Core.dll" ) 
$ie        = new-object WatiN.Core.IE("http://xyz.com") #Here you could load also Firefox with watin
$ie.TextField([watin.core.Find]::ByName("HF_Text1")).TypeText("Text1")
$ie.FileUpload([watin.core.Find]::ByName("HF_file")).Set("C:\text.txt") 
$ie.Button([watin.core.Find]::ByName("HF_Button")).Click()
$ie.WaitForComplete()
$ie.quit()

Note that you have to run Powershell in STA Mode when using WatiN (powershell.exe -sta)

Upvotes: 2

Related Questions