title: Automate Safari web browser using c# on Windows
body: <p>I wondered if anyone had successfully managed, or knew how to automate the Safari web browser on the Windows platform.</p>
  
  <p>Ideally I would like to automate Safari in a similar way to using <a href="http://msdn.microsoft.com/en-us/library/aa741317.aspx" rel="nofollow noreferrer">mshtml</a> 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 <a href="http://www.croczilla.com/jssh" rel="nofollow noreferrer">jssh</a> plug-in.</p>
  
  <p>I'm looking to automate the browser using .Net to enhance an existing automation framework <a href="http://watin.sourceforge.net/" rel="nofollow noreferrer">WatiN</a></p>
  
  <p><strong>Edit</strong>: 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.</p>
  
  <p><strong>Update: 23-03-2009</strong>:
  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: <a href="http://www.ericdlarson.com/misc/chrome_command_line_flags.html" rel="nofollow noreferrer">http://www.ericdlarson.com/misc/chrome_command_line_flags.html</a>) you can send javascript to the browser.</p>
  
  <p>Once connected to the remote debug seesion</p>
  
  <ul>
  <li>Send <strong>debug()</strong> to attach to the current tab</li>
  <li>Send any javascript command using <strong>print</strong>, i.e. print document.window.location.href</li>
  </ul>
  
  <p>We've used this method to add <a href="http://watin.svn.sourceforge.net/viewvc/watin/trunk/src/Core/Native/Chrome/" rel="nofollow noreferrer">Chrome support to WatiN</a></p>