我正在使用 Silk test 17.5 在 Chrome 51 中的 Web 应用程序上记录 .net 脚本。我必须通过打开的对话框上传文件。实现它的投注方式是什么?
谢谢你。
我正在使用 Silk test 17.5 在 Chrome 51 中的 Web 应用程序上记录 .net 脚本。我必须通过打开的对话框上传文件。实现它的投注方式是什么?
谢谢你。
不幸的是,无法使用动作记录来上传文件,但有一些方法可以通过脚本来实现。
如果您的文件上传看起来像此示例页面上的文件:http ://the-internet.herokuapp.com/upload ,您可以将要上传的文件的名称直接输入到上传控件中:
With _desktop.BrowserApplication()
With .BrowserWindow()
.DomTextField("//INPUT[@id='file-upload']").TypeKeys("c:\temp\test.txt")
.DomButton("//INPUT[@id='file-submit']").Click()
Workbench.Verify("test.txt", .DomElement("//DIV[@id='uploaded-files']").Text)
End With
End With
或者您可以单击上传控件以调出“文件打开”对话框,然后通过 Win32 API 自动执行该对话框:
With _desktop.BrowserApplication()
With .BrowserWindow()
.DomTextField("//INPUT[@id='file-upload']").Click()
End With
End With
With _desktop.Dialog("@caption='Open'")
.TextField("@caption='File name:'").SetText("c:\temp\test.txt")
.PushButton("@caption='Open'").Select()
End With
With _desktop.BrowserApplication()
With .BrowserWindow()
.DomButton("//INPUT[@id='file-submit']").Click()
Workbench.Verify("test.txt", .DomElement("//DIV[@id='uploaded-files']").Text)
End With
End With