【问题标题】:How to automate firefox with powershell?如何使用 powershell 自动化 firefox?
【发布时间】:2011-09-30 12:46:11
【问题描述】:

我目前正在使用 power shell 进行自动化,但遇到以下问题, 我在 power shell 中有自动 Internet Explorer 脚本,

但现在我需要使用它来自动化 Firefox,我已经搜索过但无法追踪, 有什么方法或者是否可以使用电源外壳自动化 FF ....需要建议。

【问题讨论】:

  • 您究竟想要自动化什么?
  • 我需要自动化 Firefox 以在我的 Web 应用程序上执行一些功能,例如登录和填写表单。
  • 能否发布一个示例,说明您如何在 Internet Explorer 中执行此操作?然后有人可以尝试将其更改为与 Firefox 一起使用。

标签: powershell powershell-2.0


【解决方案1】:

看看http://watin.org/你可以使用支持多种浏览器的watin.dll..

我开始使用它是因为我需要一个文件上传,这是 InternetExplorer.Application 无法做到的......

小sn-p 让你开始:

$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()

注意,使用WatiN时必须在STA模式下运行Powershell (powershell.exe -sta)

【讨论】:

猜你喜欢
  • 2021-06-22
  • 2018-03-28
  • 2017-12-10
  • 2011-02-07
  • 2023-03-31
  • 2020-10-09
  • 2010-11-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多