Automate Safari web browser using c# on Windows

北慕城南 提交于 2020-01-22 15:27:09

问题


I wondered if anyone had successfully managed, or knew how to automate the Safari web browser on the Windows platform.

Ideally I would like to automate Safari in a similar way to using mshtml for Internet Explorer. Failing that a way to inject JavaScript into the running process would also be fine. I've used the JavaScript injection method to automate Firefox via the jssh plug-in.

I'm looking to automate the browser using .Net to enhance an existing automation framework WatiN

Edit: Whilst I think selenium might be a great choice for automating Safari in certain scenarios, I would like to use a solution that does not require installing software on the server i.e. Selenium Core or an intermediate proxy server in the case of Selenium Remote Control.

Update: 23-03-2009: Whilst I've not yet found a way to automate Safari, I have found a way to automate Webkit inside of Chrome. If you run Chrome using the --remote-shell-port=9999 command line switches (ref: http://www.ericdlarson.com/misc/chrome_command_line_flags.html) you can send javascript to the browser.

Once connected to the remote debug seesion

  • Send debug() to attach to the current tab
  • Send any javascript command using print, i.e. print document.window.location.href

We've used this method to add Chrome support to WatiN


回答1:


you might check my post here where I am using the method described above to automate Chrome in C#

http://markcz.wordpress.com/2012/02/18/automating-chrome-browser-from-csharp/

Martin




回答2:


I'm not sure if this helps, but the guys at ArtOfTest have added Safari support to their .Net based automation framework WebAii. Maybe you could figure out what they are doing.




回答3:


Selenium has been very useful for me for compatibility testing.




回答4:


WatiN here http://watinandmore.blogspot.com/2010/01/browserattachto-and-iattachto.html lets you automate IE and FF. It is open source, so you can have a look on how they do it.

Maybe you can adapt it to your needs?



来源:https://stackoverflow.com/questions/60609/automate-safari-web-browser-using-c-sharp-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!