# IronRuby with WatiN

**URL:** <https://www.ruby-forum.com/t/ironruby-with-watin/175887>\
**Category:** IronRuby\
**Created:** [September 22, 2009, 9:04am UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887 "2009-09-22T09:04:20Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 22, 2009, 9:04am UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/1 "2009-09-22T09:04:20Z")

</div>

Hi,  
Since, Watir is currently not supported I want to check out WatiN with  
IronRuby. Yes, I know I can use it with C# but I am interested in using  
IronRuby. I am getting the following exception:

Here is the code:

require File.dirname( **FILE** ) + ‘/bin/Debug/WatiN.Core.dll’  
require File.dirname( **FILE** ) + ‘/bin/Debug/Interop.SHDocVw.dll’  
require File.dirname( **FILE** ) + ‘/bin/Debug/Microsoft.mshtml.dll’

IE = WatiN::Core::IE

i = IE.new()

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 22, 2009, 5:44pm UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/2 "2009-09-22T17:44:07Z")

</div>

## You could try the selenium client gem that may work.

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 22, 2009, 7:36pm UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/3 "2009-09-22T19:36:32Z")

</div>

It is failing to load the Interop.SHDocVw.dll, which I believe is the  
interop assembly for IE. Hanselman discusses a similar issue with  
getting WatiN working in Powershell:  
[http://www.hanselman.com/blog/WATIRForNETWatiNApproaches08ReleaseAndAutomatingIEFromPowerShell.aspx](http://www.hanselman.com/blog/WATIRForNETWatiNApproaches08ReleaseAndAutomatingIEFromPowerShell.aspx).

It might be worth getting a very small and basic example of WatiN  
working in C# to understand how everything works, and then port it to  
IronRuby.

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 22, 2009, 7:44pm UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/4 "2009-09-22T19:44:09Z")

</div>

I created a C# application and used WatiN. It worked flawlessly and  
without  
any configuration. For some reason IronRuby is requiring something more  
to  
run the application.

On Mon, Sep 21, 2009 at 3:11 PM, Jimmy S. \<

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 22, 2009, 9:46pm UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/5 "2009-09-22T21:46:29Z")

</div>

WatiN works in STA (Single Threaded Apartment). Maybe I am missing that?  
How  
can I create STA threads in IronRuby.

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 22, 2009, 7:41pm UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/6 "2009-09-22T19:41:13Z")

</div>

You can do “igem install” against any pure-Ruby gem; only gems with  
native extensions require an IronRuby-specific gem. And “igem” is  
nothing more than a bat file to call RubyGems with IronRuby; RubyGems  
for IronRuby is identical to MRI’s version.

That being said, I don’t know what type of dependencies Selenium has.

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Mohammad A.  
Sent: Monday, September 21, 2009 3:03 PM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] IronRuby with WatiN

## I will try the Selenium Client gem. But is there any igem install selenium-client or do I have to use the Ruby version of Selenium client. On Mon, Sep 21, 2009 at 2:52 PM, Ivan Porto C. \<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote: You could try the selenium client gem that may work.

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))

On Mon, Sep 21, 2009 at 11:35 PM, Mohammad A.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:  
Hi,

Since, Watir is currently not supported I want to check out WatiN with  
IronRuby. Yes, I know I can use it with C# but I am interested in using  
IronRuby. I am getting the following exception:

Here is the code:

require File.dirname( **FILE** ) + ‘/bin/Debug/WatiN.Core.dll’  
require File.dirname( **FILE** ) + ‘/bin/Debug/Interop.SHDocVw.dll’  
require File.dirname( **FILE** ) + ‘/bin/Debug/Microsoft.mshtml.dll’

IE = WatiN::Core::IE

i = IE.new()

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 22, 2009, 9:51pm UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/7 "2009-09-22T21:51:11Z")

</div>

I will try the Selenium Client gem. But is there any igem install  
selenium-client or do I have to use the Ruby version of Selenium client.

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 23, 2009, 12:01am UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/8 "2009-09-23T00:01:43Z")

</div>

I copied the .ddl from System32 and placed in my project folder. But it  
is  
still giving me the same problem.  
require File.dirname( **FILE** ) + ‘/bin/Debug/WatiN.Core.dll’  
require File.dirname( **FILE** ) + ‘/bin/Debug/Interop.SHDocVw,  
Version=1.1.0.0, Culture=neutral, PublicKeyToken=db7cfd3acb5ad44e’

IE = WatiN::Core::IE

i = IE.new()

On Mon, Sep 21, 2009 at 3:11 PM, Jimmy S. \<

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 23, 2009, 4:24am UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/9 "2009-09-23T04:24:13Z")

</div>

Hi,  
I tried it and it did not work. Here are the details:

C:\Projects\ILoveIronRuby\ILoveIronRuby\testing\bin\Debug\>ir  
ironrubywatin.rb  
ironrubywatin.rb:8: iwebBrowser2 needs to implement shdocvw.IWebBrowser2  
(Argume  
ntError)

Thanks,  
Azam

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 23, 2009, 1:09am UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/10 "2009-09-23T01:09:06Z")

</div>

IronRuby start the main thread in STA mode as can be seen by this  
command:

c:\>rbx -e “puts System::Threading::Thread.CurrentThread.ApartmentState”  
STA

However, new threads are created in MTA mode (the default).

c:\>rbx -e “Thread.new{ puts  
System::Threading::Thread.CurrentThread.ApartmentState }.join”  
MTA

I doubt this is the problem as the error messages would be something  
else. For C#, are all dlls next to the C# application exe? Try running  
the IronRuby repro out of bin\Debug to reduce the issues that could  
cause problems. If you cannot get even “require ‘Microsoft.mshtml.dll’”  
to work, then you know its some basic problem unrelated to Watin.

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Mohammad A.  
Sent: Monday, September 21, 2009 7:07 PM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] IronRuby with WatiN

WatiN works in STA (Single Threaded Apartment). Maybe I am missing that?  
How can I create STA threads in IronRuby.  
On Mon, Sep 21, 2009 at 7:03 PM, Mohammad A.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:  
I created a C# application and used WatiN. It worked flawlessly and  
without any configuration. For some reason IronRuby is requiring  
something more to run the application.  
On Mon, Sep 21, 2009 at 3:11 PM, Jimmy S.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

You can do “igem install” against any pure-Ruby gem; only gems with  
native extensions require an IronRuby-specific gem. And “igem” is  
nothing more than a bat file to call RubyGems with IronRuby; RubyGems  
for IronRuby is identical to MRI’s version.

That being said, I don’t know what type of dependencies Selenium has.

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Mohammad A.  
Sent: Monday, September 21, 2009 3:03 PM

To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

I will try the Selenium Client gem. But is there any igem install  
selenium-client or do I have to use the Ruby version of Selenium client.

On Mon, Sep 21, 2009 at 2:52 PM, Ivan Porto C.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

## You could try the selenium client gem that may work.

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))

On Mon, Sep 21, 2009 at 11:35 PM, Mohammad A.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

Hi,

Since, Watir is currently not supported I want to check out WatiN with  
IronRuby. Yes, I know I can use it with C# but I am interested in using  
IronRuby. I am getting the following exception:

Here is the code:

require File.dirname( **FILE** ) + ‘/bin/Debug/WatiN.Core.dll’

require File.dirname( **FILE** ) + ‘/bin/Debug/Interop.SHDocVw.dll’

require File.dirname( **FILE** ) + ‘/bin/Debug/Microsoft.mshtml.dll’

IE = WatiN::Core::IE

i = IE.new()

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 23, 2009, 4:31am UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/11 "2009-09-23T04:31:15Z")

</div>

Azam, without seeing the contents of ironrubywatin.rb, or what a correct  
C# WatiN program looks like … we can’t help much. So, either send the  
Ruby and C# source so we can compare, or can you package up your testing  
directory into a zip file and host it somewhere online so we can try it  
ourselves? Please don’t attach it to this thread, as the mailing list  
will regect a large attachment.

~js

* * *

From: removed\_email\_address@domain.invalid  
[removed\_email\_address@domain.invalid] on behalf of Mohammad A.  
[removed\_email\_address@domain.invalid]  
Sent: Tuesday, September 22, 2009 10:40 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] IronRuby with WatiN

Hi,

I tried it and it did not work. Here are the details:

C:\Projects\ILoveIronRuby\ILoveIronRuby\testing\bin\Debug\>ir  
ironrubywatin.rb  
ironrubywatin.rb:8: iwebBrowser2 needs to implement shdocvw.IWebBrowser2  
(Argume  
ntError)

Thanks,  
Azam

On Tue, Sep 22, 2009 at 10:10 AM, Shri B.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

IronRuby start the main thread in STA mode as can be seen by this  
command:

c:\>rbx -e “puts System::Threading::Thread.CurrentThread.ApartmentState”

STA

However, new threads are created in MTA mode (the default).

c:\>rbx -e “Thread.new{ puts  
System::Threading::Thread.CurrentThread.ApartmentState }.join”

MTA

I doubt this is the problem as the error messages would be something  
else. For C#, are all dlls next to the C# application exe? Try running  
the IronRuby repro out of bin\Debug to reduce the issues that could  
cause problems. If you cannot get even â€œrequire â€˜Microsoft.mshtml.dllâ€™â€  
to work, then you know its some basic problem unrelated to Watin.

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Mohammad A.  
Sent: Monday, September 21, 2009 7:07 PM

To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

WatiN works in STA (Single Threaded Apartment). Maybe I am missing that?  
How can I create STA threads in IronRuby.

On Mon, Sep 21, 2009 at 7:03 PM, Mohammad A.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

I created a C# application and used WatiN. It worked flawlessly and  
without any configuration. For some reason IronRuby is requiring  
something more to run the application.

On Mon, Sep 21, 2009 at 3:11 PM, Jimmy S.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

You can do “igem install” against any pure-Ruby gem; only gems with  
native extensions require an IronRuby-specific gem. And “igem” is  
nothing more than a bat file to call RubyGems with IronRuby; RubyGems  
for IronRuby is identical to MRI’s version.

That being said, I don’t know what type of dependencies Selenium has.

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Mohammad A.  
Sent: Monday, September 21, 2009 3:03 PM

To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

I will try the Selenium Client gem. But is there any igem install  
selenium-client or do I have to use the Ruby version of Selenium client.

On Mon, Sep 21, 2009 at 2:52 PM, Ivan Porto C.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

## You could try the selenium client gem that may work.

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))

On Mon, Sep 21, 2009 at 11:35 PM, Mohammad A.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

Hi,

Since, Watir is currently not supported I want to check out WatiN with  
IronRuby. Yes, I know I can use it with C# but I am interested in using  
IronRuby. I am getting the following exception:

Here is the code:

require File.dirname( **FILE** ) + ‘/bin/Debug/WatiN.Core.dll’

require File.dirname( **FILE** ) + ‘/bin/Debug/Interop.SHDocVw.dll’

require File.dirname( **FILE** ) + ‘/bin/Debug/Microsoft.mshtml.dll’

IE = WatiN::Core::IE

i = IE.new()

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 23, 2009, 6:17am UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/12 "2009-09-23T06:17:49Z")

</div>

Here are the contents of ironrubywatin.rb file:

require ‘WatiN.Core.dll’  
require ‘Interop.SHDocVw.dll’

IE = WatiN::Core::IE

i = IE.new(‘[http://localhost:1879/Login.aspx](http://localhost:1879/Login.aspx)’)

There is no C# file.

I run using:

ir.exe ironrubywatin.rb

Everything is placed in the bin/Debug folder hence no path reference is  
required!

Thanks,  
Azam

On Tue, Sep 22, 2009 at 10:56 AM, Jimmy S. \<

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 23, 2009, 9:59am UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/13 "2009-09-23T09:59:43Z")

</div>

By “C# code” i meant the equivalent C# program that you said worked:

removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I created a C# application and used WatiN. It worked flawlessly and without any configuration

Really I’d like to see your full C# project to see what is missing in  
the Ruby script. Otherwise, I’ll just go to watin’s website myself and  
try it out, but I can’t guarantee I’ll get back to you soon. I know  
finding bugs is frustrating, but providing as much information as  
possible, including a runnable self-contained repro, will help us  
reproduce the issue and get back to you with a fix. Otherwise we’re just  
wasting time.

For future reference, here’s the info asked for when reporting bugs:  
[http://ironruby.codeplex.com/Wiki/View.aspx?title=Project%20Documentation&referringTitle=Home](http://ironruby.codeplex.com/Wiki/View.aspx?title=Project%20Documentation&referringTitle=Home)

~js

* * *

From: removed\_email\_address@domain.invalid  
[removed\_email\_address@domain.invalid] on behalf of Mohammad A.  
[removed\_email\_address@domain.invalid]  
Sent: Tuesday, September 22, 2009 11:07 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] IronRuby with WatiN

Here are the contents of ironrubywatin.rb file:

require ‘WatiN.Core.dll’  
require ‘Interop.SHDocVw.dll’

IE = WatiN::Core::IE

i = IE.new(‘[http://localhost:1879/Login.aspx](http://localhost:1879/Login.aspx)’)

There is no C# file.

I run using:

ir.exe ironrubywatin.rb

Everything is placed in the bin/Debug folder hence no path reference is  
required!

Thanks,  
Azam

On Tue, Sep 22, 2009 at 10:56 AM, Jimmy S.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:  
Azam, without seeing the contents of ironrubywatin.rb, or what a correct  
C# WatiN program looks like … we can’t help much. So, either send the  
Ruby and C# source so we can compare, or can you package up your testing  
directory into a zip file and host it somewhere online so we can try it  
ourselves? Please don’t attach it to this thread, as the mailing list  
will regect a large attachment.

~js

* * *

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
on behalf of Mohammad A.  
[removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Tuesday, September 22, 2009 10:40 AM

To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

Hi,

I tried it and it did not work. Here are the details:

C:\Projects\ILoveIronRuby\ILoveIronRuby\testing\bin\Debug\>ir  
ironrubywatin.rb  
ironrubywatin.rb:8: iwebBrowser2 needs to implement shdocvw.IWebBrowser2  
(Argume  
ntError)

Thanks,  
Azam

On Tue, Sep 22, 2009 at 10:10 AM, Shri B.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

IronRuby start the main thread in STA mode as can be seen by this  
command:

c:\>rbx -e “puts System::Threading::Thread.CurrentThread.ApartmentState”

STA

However, new threads are created in MTA mode (the default).

c:\>rbx -e “Thread.new{ puts  
System::Threading::Thread.CurrentThread.ApartmentState }.join”

MTA

I doubt this is the problem as the error messages would be something  
else. For C#, are all dlls next to the C# application exe? Try running  
the IronRuby repro out of bin\Debug to reduce the issues that could  
cause problems. If you cannot get even â€œrequire â€˜Microsoft.mshtml.dllâ€™â€  
to work, then you know its some basic problem unrelated to Watin.

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Mohammad A.  
Sent: Monday, September 21, 2009 7:07 PM

To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

WatiN works in STA (Single Threaded Apartment). Maybe I am missing that?  
How can I create STA threads in IronRuby.

On Mon, Sep 21, 2009 at 7:03 PM, Mohammad A.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

I created a C# application and used WatiN. It worked flawlessly and  
without any configuration. For some reason IronRuby is requiring  
something more to run the application.

On Mon, Sep 21, 2009 at 3:11 PM, Jimmy S.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

You can do “igem install” against any pure-Ruby gem; only gems with  
native extensions require an IronRuby-specific gem. And “igem” is  
nothing more than a bat file to call RubyGems with IronRuby; RubyGems  
for IronRuby is identical to MRI’s version.

That being said, I don’t know what type of dependencies Selenium has.

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Mohammad A.  
Sent: Monday, September 21, 2009 3:03 PM

To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

I will try the Selenium Client gem. But is there any igem install  
selenium-client or do I have to use the Ruby version of Selenium client.

On Mon, Sep 21, 2009 at 2:52 PM, Ivan Porto C.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

## You could try the selenium client gem that may work.

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))

On Mon, Sep 21, 2009 at 11:35 PM, Mohammad A.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

Hi,

Since, Watir is currently not supported I want to check out WatiN with  
IronRuby. Yes, I know I can use it with C# but I am interested in using  
IronRuby. I am getting the following exception:

Here is the code:

require File.dirname( **FILE** ) + ‘/bin/Debug/WatiN.Core.dll’

require File.dirname( **FILE** ) + ‘/bin/Debug/Interop.SHDocVw.dll’

require File.dirname( **FILE** ) + ‘/bin/Debug/Microsoft.mshtml.dll’

IE = WatiN::Core::IE

i = IE.new()

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 23, 2009, 3:15pm UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/14 "2009-09-23T15:15:51Z")

</div>

Thanks for the answer! That does resolve the issue. I wonder how you  
found  
that ruby is calling the object version of the constructor and not the  
string one.  
Also, how does IronRuby knows whether to call ie.Goto(string) or  
ie.Goto(Uri);

Thanks,  
Azam

On Tue, Sep 22, 2009 at 2:42 PM, Jimmy S. \<

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 23, 2009, 3:12pm UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/15 "2009-09-23T15:12:20Z")

</div>

Taking a look at the WatiN::Core::IE overloaded constructors, you can  
immediately see the issue:

public IE(bool createInNewProcess);

public IE(object iwebBrowser2);

public IE(string url);

public IE(Uri uri);

When calling IE.new(‘[http://google.com](http://google.com)’), the string is a Ruby string,  
which is resolving to the object overload rather than the string  
overload. A work-around currently will be to force the string to be a  
CLR string:

IE.new(‘[http://google.com](http://google.com)’.to\_clr\_string)

However, it’s unfortunate that IronRuby’s CLR overload resolution is  
picking the more conservative choice, rather than seeing if the Ruby  
string can be coerced into a more specific overload. JD, have you found  
this while testing? Tomas, any specific reason this is the behavior, or  
would you call it a bug? I’d vote it as a bug.

This will also work:

ie = IE.new

ie.go\_to ‘[http://google.com](http://google.com)’

Here’s the C# example ported to IronRuby:

require ‘Interop.SHDocVw’

require ‘WatiN.Core’  
include WatiN::Core

ie = IE.new

ie.go\_to ‘[http://localhost:1879/Login.aspx](http://localhost:1879/Login.aspx)’

ie.text\_field(‘txtUserName’).type\_text(‘azamsharp’)

I also verified this works from the interactive prompt, so you can use  
WatiN to control the browser interactively from IronRuby.

~Jimmy

* * *

From: removed\_email\_address@domain.invalid  
[removed\_email\_address@domain.invalid] on behalf of Jimmy S.  
[removed\_email\_address@domain.invalid]  
Sent: Tuesday, September 22, 2009 11:39 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] IronRuby with WatiN

By “C# code” i meant the equivalent C# program that you said worked:

removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I created a C# application and used WatiN. It worked flawlessly and without any configuration

Really I’d like to see your full C# project to see what is missing in  
the Ruby script. Otherwise, I’ll just go to watin’s website myself and  
try it out, but I can’t guarantee I’ll get back to you soon. I know  
finding bugs is frustrating, but providing as much information as  
possible, including a runnable self-contained repro, will help us  
reproduce the issue and get back to you with a fix. Otherwise we’re just  
wasting time.

For future reference, here’s the info asked for when reporting bugs:  
[http://ironruby.codeplex.com/Wiki/View.aspx?title=Project%20Documentation&referringTitle=Home](http://ironruby.codeplex.com/Wiki/View.aspx?title=Project%20Documentation&referringTitle=Home)

~js

* * *

From: removed\_email\_address@domain.invalid  
[removed\_email\_address@domain.invalid] on behalf of Mohammad A.  
[removed\_email\_address@domain.invalid]  
Sent: Tuesday, September 22, 2009 11:07 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] IronRuby with WatiN

Here are the contents of ironrubywatin.rb file:

require ‘WatiN.Core.dll’  
require ‘Interop.SHDocVw.dll’

IE = WatiN::Core::IE

i = IE.new(‘[http://localhost:1879/Login.aspx](http://localhost:1879/Login.aspx)’)

There is no C# file.

I run using:

ir.exe ironrubywatin.rb

Everything is placed in the bin/Debug folder hence no path reference is  
required!

Thanks,  
Azam

On Tue, Sep 22, 2009 at 10:56 AM, Jimmy S.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:  
Azam, without seeing the contents of ironrubywatin.rb, or what a correct  
C# WatiN program looks like … we can’t help much. So, either send the  
Ruby and C# source so we can compare, or can you package up your testing  
directory into a zip file and host it somewhere online so we can try it  
ourselves? Please don’t attach it to this thread, as the mailing list  
will regect a large attachment.

~js

* * *

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
on behalf of Mohammad A.  
[removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Tuesday, September 22, 2009 10:40 AM

To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

Hi,

I tried it and it did not work. Here are the details:

C:\Projects\ILoveIronRuby\ILoveIronRuby\testing\bin\Debug\>ir  
ironrubywatin.rb  
ironrubywatin.rb:8: iwebBrowser2 needs to implement shdocvw.IWebBrowser2  
(Argume  
ntError)

Thanks,  
Azam

On Tue, Sep 22, 2009 at 10:10 AM, Shri B.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

IronRuby start the main thread in STA mode as can be seen by this  
command:

c:\>rbx -e “puts System::Threading::Thread.CurrentThread.ApartmentState”

STA

However, new threads are created in MTA mode (the default).

c:\>rbx -e “Thread.new{ puts  
System::Threading::Thread.CurrentThread.ApartmentState }.join”

MTA

I doubt this is the problem as the error messages would be something  
else. For C#, are all dlls next to the C# application exe? Try running  
the IronRuby repro out of bin\Debug to reduce the issues that could  
cause problems. If you cannot get even â€œrequire â€˜Microsoft.mshtml.dllâ€™â€  
to work, then you know its some basic problem unrelated to Watin.

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Mohammad A.  
Sent: Monday, September 21, 2009 7:07 PM

To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

WatiN works in STA (Single Threaded Apartment). Maybe I am missing that?  
How can I create STA threads in IronRuby.

On Mon, Sep 21, 2009 at 7:03 PM, Mohammad A.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

I created a C# application and used WatiN. It worked flawlessly and  
without any configuration. For some reason IronRuby is requiring  
something more to run the application.

On Mon, Sep 21, 2009 at 3:11 PM, Jimmy S.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

You can do “igem install” against any pure-Ruby gem; only gems with  
native extensions require an IronRuby-specific gem. And “igem” is  
nothing more than a bat file to call RubyGems with IronRuby; RubyGems  
for IronRuby is identical to MRI’s version.

That being said, I don’t know what type of dependencies Selenium has.

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Mohammad A.  
Sent: Monday, September 21, 2009 3:03 PM

To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

I will try the Selenium Client gem. But is there any igem install  
selenium-client or do I have to use the Ruby version of Selenium client.

On Mon, Sep 21, 2009 at 2:52 PM, Ivan Porto C.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

## You could try the selenium client gem that may work.

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))

On Mon, Sep 21, 2009 at 11:35 PM, Mohammad A.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

Hi,

Since, Watir is currently not supported I want to check out WatiN with  
IronRuby. Yes, I know I can use it with C# but I am interested in using  
IronRuby. I am getting the following exception:

Here is the code:

require File.dirname( **FILE** ) + ‘/bin/Debug/WatiN.Core.dll’

require File.dirname( **FILE** ) + ‘/bin/Debug/Interop.SHDocVw.dll’

require File.dirname( **FILE** ) + ‘/bin/Debug/Microsoft.mshtml.dll’

IE = WatiN::Core::IE

i = IE.new()

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 23, 2009, 5:21pm UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/16 "2009-09-23T17:21:44Z")

</div>

I agree the ctor is poorly designed. Since there’s a simple workaround,  
and your explanation of the existing behavior makes sense, then I’m also  
convinced this is “by design”. I’ll document this as a “gotcha”, and  
suggest that this is poor design for overloads. WatiN should definitely  
change this; anyone want to submit a patch to them?

~Jimmy  
Sent from my phone

On Sep 22, 2009, at 1:38 PM, “Tomas M.”  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

This behavior is by design.

MutableString → object requires an up-cast  
MutableString → string requires an explicit conversion

Overload resolver prefers up-cast over an explicit conversion. With  
explicit conversion you can lose some information (e.g. encoding of the  
string) and also get an exception (if theMutableString represents binary  
data not convertible to UTF16 string).

The constructor seems to be poorly designed since it actually accepts  
only objects that implement IWebBrowser2 (you get argument exception  
â€œiwebBrowser2 needs to implement shdocvw.IWebBrowser2â€ if you pass  
something else). I donâ€™t a reason why the constructor shouldnâ€™t take  
IWebBrowser2 parameter.

Tomas

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Jimmy  
Schementi  
Sent: Tuesday, September 22, 2009 12:42 PM  
To: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

Taking a look at the WatiN::Core::IE overloaded constructors, you can  
immediately see the issue:

public IE(bool createInNewProcess);

public IE(object iwebBrowser2);

public IE(string url);

public IE(Uri uri);

When calling IE.new(‘[http://google.com](http://google.com)’), the string is a Ruby string,  
which is resolving to the object overload rather than the string  
overload. A work-around currently will be to force the string to be a  
CLR string:

IE.new(‘[http://google.com](http://google.com)’.to\_clr\_string)

However, it’s unfortunate that IronRuby’s CLR overload resolution is  
picking the more conservative choice, rather than seeing if the Ruby  
string can be coerced into a more specific overload. JD, have you found  
this while testing? Tomas, any specific reason this is the behavior, or  
would you call it a bug? I’d vote it as a bug.

This will also work:

ie = IE.new

ie.go\_to ‘[http://google.com’](http://google.com')[http://google.com](http://google.com)’

Here’s the C# example ported to IronRuby:

require ‘Interop.SHDocVw’

require ‘WatiN.Core’  
include WatiN::Core

ie = IE.new

ie.go\_to  
‘[http://localhost:1879/Login.aspx’](http://localhost:1879/Login.aspx')[http://localhost:1879/Login.aspx](http://localhost:1879/Login.aspx)’

ie.text\_field(‘txtUserName’).type\_text(‘azamsharp’)

I also verified this works from the interactive prompt, so you can use  
WatiN to control the browser interactively from IronRuby.

~Jimmy

* * *

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[removed\_email\_address@domain.invalid] on behalf of Jimmy S.  
[removed\_email\_address@domain.invalid]  
Sent: Tuesday, September 22, 2009 11:39 AM  
To: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN  
By “C# code” i meant the equivalent C# program that you said worked:

[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I created a C# application and used WatiN. It worked flawlessly and without any configuration

Really I’d like to see your full C# project to see what is missing in  
the Ruby script. Otherwise, I’ll just go to watin’s website myself and  
try it out, but I can’t guarantee I’ll get back to you soon. I know  
finding bugs is frustrating, but providing as much information as  
possible, including a runnable self-contained repro, will help us  
reproduce the issue and get back to you with a fix. Otherwise we’re just  
wasting time.

For future reference, here’s the info asked for when reporting bugs:  
[http://ironruby.codeplex.com/Wiki/View.aspx?title=Project%20Documentation&referringTitle=Home](http://ironruby.codeplex.com/Wiki/View.aspx?title=Project%20Documentation&referringTitle=Home)  
[http://ironruby.codeplex.com/Wiki/View.aspx?title=Project%20Documentation&referringTitle=Home](http://ironruby.codeplex.com/Wiki/View.aspx?title=Project%20Documentation&referringTitle=Home)

~js

* * *

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[removed\_email\_address@domain.invalid] on behalf of Mohammad A.  
[removed\_email\_address@domain.invalid]  
Sent: Tuesday, September 22, 2009 11:07 AM  
To: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN  
Here are the contents of ironrubywatin.rb file:

require ‘WatiN.Core.dll’  
require ‘Interop.SHDocVw.dll’

IE = WatiN::Core::IE

i =  
IE.new(‘[http://localhost:1879/Login.aspx](http://localhost:1879/Login.aspx)[http://localhost:1879/Login.aspx](http://localhost:1879/Login.aspx)’)

There is no C# file.

I run using:

ir.exe ironrubywatin.rb

Everything is placed in the bin/Debug folder hence no path reference is  
required!

Thanks,  
Azam

On Tue, Sep 22, 2009 at 10:56 AM, Jimmy S.  
\<[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:  
Azam, without seeing the contents of ironrubywatin.rb, or what a correct  
C# WatiN program looks like … we can’t help much. So, either send the  
Ruby and C# source so we can compare, or can you package up your testing  
directory into a zip file and host it somewhere online so we can try it  
ourselves? Please don’t attach it to this thread, as the mailing list  
will regect a large attachment.

~js

* * *

From: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
on behalf of Mohammad A.  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Tuesday, September 22, 2009 10:40 AM

To: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

Hi,

I tried it and it did not work. Here are the details:

C:\Projects\ILoveIronRuby\ILoveIronRuby\testing\bin\Debug\>ir  
ironrubywatin.rb  
ironrubywatin.rb:8: iwebBrowser2 needs to implement shdocvw.IWebBrowser2  
(Argume  
ntError)

Thanks,  
Azam

On Tue, Sep 22, 2009 at 10:10 AM, Shri B.  
\<[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

IronRuby start the main thread in STA mode as can be seen by this  
command:

c:\>rbx -e “puts System::Threading::Thread.CurrentThread.ApartmentState”

STA

However, new threads are created in MTA mode (the default).

c:\>rbx -e “Thread.new{ puts  
System::Threading::Thread.CurrentThread.ApartmentState }.join”

MTA

I doubt this is the problem as the error messages would be something  
else. For C#, are all dlls next to the C# application exe? Try running  
the IronRuby repro out of bin\Debug to reduce the issues that could  
cause problems. If you cannot get even â€œrequire â€˜Microsoft.mshtml.dllâ€™â€  
to work, then you know its some basic problem unrelated to Watin.

From: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[mailto:[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Mohammad A.  
Sent: Monday, September 21, 2009 7:07 PM

To: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

WatiN works in STA (Single Threaded Apartment). Maybe I am missing that?  
How can I create STA threads in IronRuby.

On Mon, Sep 21, 2009 at 7:03 PM, Mohammad A.  
\<[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

I created a C# application and used WatiN. It worked flawlessly and  
without any configuration. For some reason IronRuby is requiring  
something more to run the application.

On Mon, Sep 21, 2009 at 3:11 PM, Jimmy S.  
\<[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

You can do “igem install” against any pure-Ruby gem; only gems with  
native extensions require an IronRuby-specific gem. And “igem” is  
nothing more than a bat file to call RubyGems with IronRuby; RubyGems  
for IronRuby is identical to MRI’s version.

That being said, I don’t know what type of dependencies Selenium has.

From: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[mailto:[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Mohammad A.  
Sent: Monday, September 21, 2009 3:03 PM

To: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

I will try the Selenium Client gem. But is there any igem install  
selenium-client or do I have to use the Ruby version of Selenium client.

On Mon, Sep 21, 2009 at 2:52 PM, Ivan Porto C.  
\<[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

## You could try the selenium client gem that may work.

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz) [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim) [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action  
([http://manning.com/carrero](http://manning.com/carrero)[http://manning.com/carrero](http://manning.com/carrero))

On Mon, Sep 21, 2009 at 11:35 PM, Mohammad A.  
\<[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

Hi,

Since, Watir is currently not supported I want to check out WatiN with  
IronRuby. Yes, I know I can use it with C# but I am interested in using  
IronRuby. I am getting the following exception:

Here is the code:

require File.dirname( **FILE** ) + ‘/bin/Debug/WatiN.Core.dll’

require File.dirname( **FILE** ) + ‘/bin/Debug/Interop.SHDocVw.dll’

require File.dirname( **FILE** ) + ‘/bin/Debug/Microsoft.mshtml.dll’

IE = WatiN::Core::IE

i = IE.new()

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[http://www.highoncoding.com](http://www.highoncoding.com)[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[http://www.azamsharp.com](http://www.azamsharp.com)[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

* * *

Ironruby-core mailing list  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[http://www.highoncoding.com](http://www.highoncoding.com)[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[http://www.azamsharp.com](http://www.azamsharp.com)[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[http://www.highoncoding.com](http://www.highoncoding.com)[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[http://www.azamsharp.com](http://www.azamsharp.com)[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[http://www.highoncoding.com](http://www.highoncoding.com)[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[http://www.azamsharp.com](http://www.azamsharp.com)[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[http://www.highoncoding.com](http://www.highoncoding.com)[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[http://www.azamsharp.com](http://www.azamsharp.com)[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[http://www.highoncoding.com](http://www.highoncoding.com)[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[http://www.azamsharp.com](http://www.azamsharp.com)[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 23, 2009, 5:31pm UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/17 "2009-09-23T17:31:07Z")

</div>

On Sep 22, 2009, at 1:16 PM, “Mohammad A.”  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

Thanks for the answer! That does resolve the issue. I wonder how you  
found that ruby is calling the object version of the constructor and not  
the string one.

Once I saw their code, your error msg made it clear that it was calling  
the object ctor. Plus, whenever a ruby object is passed to a method  
group that has object as a choice for an argument, it will select that  
overload.

Also, how does IronRuby knows whether to call ie.Goto(string) or  
ie.Goto(Uri);

By the type of object you give it 🙂 Ruby has a type system, so at  
runtime it can figure out what method to call based on the argument  
provided.

Thanks,  
Azam

On Tue, Sep 22, 2009 at 2:42 PM, Jimmy S.  
\<[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

Taking a look at the WatiN::Core::IE overloaded constructors, you can  
immediately see the issue:

public IE(bool createInNewProcess);

public IE(object iwebBrowser2);

public

IE(string url);

public IE(Uri uri);

When calling IE.new(‘[http://google.com](http://google.com)[http://google.com](http://google.com)’), the string  
is a Ruby string, which is resolving to the object overload rather than  
the string overload. A work-around currently will be to force the string  
to be a CLR string:

IE.new(‘[http://google.com](http://google.com)[http://google.com](http://google.com)’.to\_clr\_string)

However, it’s unfortunate that IronRuby’s CLR overload resolution is  
picking the more conservative choice, rather than seeing if the Ruby  
string can be coerced into a more specific overload. JD, have you found  
this while testing? Tomas, any specific reason this is the behavior, or  
would you call it a bug? I’d vote it as a bug.

This will also work:

ie = IE.new

ie.go\_to ‘[http://google.com](http://google.com)[http://google.com](http://google.com)’

Here’s the C# example ported to IronRuby:

require ‘Interop.SHDocVw’

require ‘WatiN.Core’  
include WatiN::Core

ie = IE.new

ie.go\_to  
‘[http://localhost:1879/Login.aspx](http://localhost:1879/Login.aspx)[http://localhost:1879/Login.aspx](http://localhost:1879/Login.aspx)’

ie.text\_field(‘txtUserName’).type\_text(‘azamsharp’)

I also verified this works from the interactive prompt, so you can use  
WatiN to control the browser interactively from IronRuby.

~Jimmy

* * *

From: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
on behalf of Jimmy S.  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Tuesday, September 22, 2009 11:39 AM

To: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

By “C# code” i meant the equivalent C# program that you said worked:

[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I created a C# application and used WatiN. It worked flawlessly and without any configuration

Really I’d like to see your full C# project to see what is missing in  
the Ruby script. Otherwise, I’ll just go to watin’s website myself and  
try it out, but I can’t guarantee I’ll get back to you soon. I know  
finding bugs is frustrating, but providing as much information as  
possible, including a runnable self-contained repro, will help us  
reproduce the issue and get back to you with a fix. Otherwise we’re just  
wasting time.

For future reference, here’s the info asked for when reporting bugs:  
[http://ironruby.codeplex.com/Wiki/View.aspx?title=Project%20Documentation&referringTitle=Home](http://ironruby.codeplex.com/Wiki/View.aspx?title=Project%20Documentation&referringTitle=Home)  
[http://ironruby.codeplex.com/Wiki/View.aspx?title=Project%20Documentation&referringTitle=Home](http://ironruby.codeplex.com/Wiki/View.aspx?title=Project%20Documentation&referringTitle=Home)

~js

* * *

From: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
on behalf of Mohammad A.  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Tuesday, September 22, 2009 11:07 AM  
To: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

Here are the contents of ironrubywatin.rb file:

require ‘WatiN.Core.dll’  
require ‘Interop.SHDocVw.dll’

IE = WatiN::Core::IE

i =  
IE.new(‘[http://localhost:1879/Login.aspx](http://localhost:1879/Login.aspx)[http://localhost:1879/Login.aspx](http://localhost:1879/Login.aspx)’)

There is no C# file.

I run using:

ir.exe ironrubywatin.rb

Everything is placed in the bin/Debug folder hence no path reference is  
required!

Thanks,  
Azam

On Tue, Sep 22, 2009 at 10:56 AM, Jimmy S.  
\<[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:  
Azam, without seeing the contents of ironrubywatin.rb, or what a correct  
C# WatiN program looks like … we can’t help much. So, either send the  
Ruby and C# source so we can compare, or can you package up your testing  
directory into a zip file and host it somewhere online so we can try it  
ourselves? Please don’t attach it to this thread, as the mailing list  
will regect a large attachment.

~js

* * *

From: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
on behalf of Mohammad A.  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Tuesday, September 22, 2009 10:40 AM

To: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

Hi,

I tried it and it did not work. Here are the details:

C:\Projects\ILoveIronRuby\ILoveIronRuby\testing\bin\Debug\>ir  
ironrubywatin.rb  
ironrubywatin.rb:8: iwebBrowser2 needs to implement shdocvw.IWebBrowser2  
(Argume  
ntError)

Thanks,  
Azam

On Tue, Sep 22, 2009 at 10:10 AM, Shri B.  
\<[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

IronRuby start the main thread in STA mode as can be seen by this  
command:

c:\>rbx -e “puts System::Threading::Thread.CurrentThread.ApartmentState”

STA

However, new threads are created in MTA mode (the default).

c:\>rbx -e “Thread.new{ puts  
System::Threading::Thread.CurrentThread.ApartmentState }.join”

MTA

I doubt this is the problem as the error messages would be something  
else. For C#, are all dlls next to the C# application exe? Try running  
the IronRuby repro out of bin\Debug to reduce the issues that could  
cause problems. If you cannot get even â€œrequire â€˜Microsoft.mshtml.dllâ€™â€  
to work, then you know its some basic problem unrelated to Watin.

From: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[mailto:[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Mohammad A.  
Sent: Monday, September 21, 2009 7:07 PM

To: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

WatiN works in STA (Single Threaded Apartment). Maybe I am missing that?  
How can I create STA threads in IronRuby.

On Mon, Sep 21, 2009 at 7:03 PM, Mohammad A.  
\<[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

I created a C# application and used WatiN. It worked flawlessly and  
without any configuration. For some reason IronRuby is requiring  
something more to run the application.

On Mon, Sep 21, 2009 at 3:11 PM, Jimmy S.  
\<[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

You can do “igem install” against any pure-Ruby gem; only gems with  
native extensions require an IronRuby-specific gem. And “igem” is  
nothing more than a bat file to call RubyGems with IronRuby; RubyGems  
for IronRuby is identical to MRI’s version.

That being said, I don’t know what type of dependencies Selenium has.

From: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[mailto:[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Mohammad A.  
Sent: Monday, September 21, 2009 3:03 PM

To: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

I will try the Selenium Client gem. But is there any igem install  
selenium-client or do I have to use the Ruby version of Selenium client.

On Mon, Sep 21, 2009 at 2:52 PM, Ivan Porto C.  
\<[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

## You could try the selenium client gem that may work.

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz) [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim) [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action  
([http://manning.com/carrero](http://manning.com/carrero)[http://manning.com/carrero](http://manning.com/carrero))

On Mon, Sep 21, 2009 at 11:35 PM, Mohammad A.  
\<[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

Hi,

Since, Watir is currently not supported I want to check out WatiN with  
IronRuby. Yes, I know I can use it with C# but I am interested in using  
IronRuby. I am getting the following exception:

Here is the code:

require File.dirname( **FILE** ) + ‘/bin/Debug/WatiN.Core.dll’

require File.dirname( **FILE** ) + ‘/bin/Debug/Interop.SHDocVw.dll’

require File.dirname( **FILE** ) + ‘/bin/Debug/Microsoft.mshtml.dll’

IE = WatiN::Core::IE

i = IE.new()

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[http://www.highoncoding.com](http://www.highoncoding.com)[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[http://www.azamsharp.com](http://www.azamsharp.com)[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

* * *

Ironruby-core mailing list  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[http://www.highoncoding.com](http://www.highoncoding.com)[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[http://www.azamsharp.com](http://www.azamsharp.com)[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[http://www.highoncoding.com](http://www.highoncoding.com)[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[http://www.azamsharp.com](http://www.azamsharp.com)[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[http://www.highoncoding.com](http://www.highoncoding.com)[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[http://www.azamsharp.com](http://www.azamsharp.com)[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[http://www.highoncoding.com](http://www.highoncoding.com)[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[http://www.azamsharp.com](http://www.azamsharp.com)[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[http://www.highoncoding.com](http://www.highoncoding.com)[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[http://www.azamsharp.com](http://www.azamsharp.com)[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[http://www.highoncoding.com](http://www.highoncoding.com)[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[http://www.azamsharp.com](http://www.azamsharp.com)[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 23, 2009, 6:06pm UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/18 "2009-09-23T18:06:50Z")

</div>

This behavior is by design.

MutableString → object requires an up-cast  
MutableString → string requires an explicit conversion

Overload resolver prefers up-cast over an explicit conversion. With  
explicit conversion you can lose some information (e.g. encoding of the  
string) and also get an exception (if theMutableString represents binary  
data not convertible to UTF16 string).

The constructor seems to be poorly designed since it actually accepts  
only objects that implement IWebBrowser2 (you get argument exception  
“iwebBrowser2 needs to implement shdocvw.IWebBrowser2” if you pass  
something else). I don’t a reason why the constructor shouldn’t take  
IWebBrowser2 parameter.

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Jimmy  
Schementi  
Sent: Tuesday, September 22, 2009 12:42 PM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] IronRuby with WatiN

Taking a look at the WatiN::Core::IE overloaded constructors, you can  
immediately see the issue:

public IE(bool createInNewProcess);

public IE(object iwebBrowser2);

public IE(string url);

public IE(Uri uri);

When calling IE.new(‘[http://google.com](http://google.com)’), the string is a Ruby string,  
which is resolving to the object overload rather than the string  
overload. A work-around currently will be to force the string to be a  
CLR string:

IE.new(‘[http://google.com](http://google.com)’.to\_clr\_string)

However, it’s unfortunate that IronRuby’s CLR overload resolution is  
picking the more conservative choice, rather than seeing if the Ruby  
string can be coerced into a more specific overload. JD, have you found  
this while testing? Tomas, any specific reason this is the behavior, or  
would you call it a bug? I’d vote it as a bug.

This will also work:

ie = IE.new

ie.go\_to ‘[http://google.com](http://google.com)’

Here’s the C# example ported to IronRuby:

require ‘Interop.SHDocVw’

require ‘WatiN.Core’  
include WatiN::Core

ie = IE.new

ie.go\_to ‘[http://localhost:1879/Login.aspx](http://localhost:1879/Login.aspx)’

ie.text\_field(‘txtUserName’).type\_text(‘azamsharp’)

I also verified this works from the interactive prompt, so you can use  
WatiN to control the browser interactively from IronRuby.

~Jimmy

* * *

From: removed\_email\_address@domain.invalid  
[removed\_email\_address@domain.invalid] on behalf of Jimmy S.  
[removed\_email\_address@domain.invalid]  
Sent: Tuesday, September 22, 2009 11:39 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] IronRuby with WatiN  
By “C# code” i meant the equivalent C# program that you said worked:

removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I created a C# application and used WatiN. It worked flawlessly and without any configuration

Really I’d like to see your full C# project to see what is missing in  
the Ruby script. Otherwise, I’ll just go to watin’s website myself and  
try it out, but I can’t guarantee I’ll get back to you soon. I know  
finding bugs is frustrating, but providing as much information as  
possible, including a runnable self-contained repro, will help us  
reproduce the issue and get back to you with a fix. Otherwise we’re just  
wasting time.

For future reference, here’s the info asked for when reporting bugs:  
[http://ironruby.codeplex.com/Wiki/View.aspx?title=Project%20Documentation&referringTitle=Home](http://ironruby.codeplex.com/Wiki/View.aspx?title=Project%20Documentation&referringTitle=Home)

~js

* * *

From: removed\_email\_address@domain.invalid  
[removed\_email\_address@domain.invalid] on behalf of Mohammad A.  
[removed\_email\_address@domain.invalid]  
Sent: Tuesday, September 22, 2009 11:07 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] IronRuby with WatiN  
Here are the contents of ironrubywatin.rb file:

require ‘WatiN.Core.dll’  
require ‘Interop.SHDocVw.dll’

IE = WatiN::Core::IE

i = IE.new(‘[http://localhost:1879/Login.aspx](http://localhost:1879/Login.aspx)’)

There is no C# file.

I run using:

ir.exe ironrubywatin.rb

Everything is placed in the bin/Debug folder hence no path reference is  
required!

Thanks,  
Azam

On Tue, Sep 22, 2009 at 10:56 AM, Jimmy S.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:  
Azam, without seeing the contents of ironrubywatin.rb, or what a correct  
C# WatiN program looks like … we can’t help much. So, either send the  
Ruby and C# source so we can compare, or can you package up your testing  
directory into a zip file and host it somewhere online so we can try it  
ourselves? Please don’t attach it to this thread, as the mailing list  
will regect a large attachment.

~js

* * *

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
on behalf of Mohammad A.  
[removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Tuesday, September 22, 2009 10:40 AM

To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

Hi,

I tried it and it did not work. Here are the details:

C:\Projects\ILoveIronRuby\ILoveIronRuby\testing\bin\Debug\>ir  
ironrubywatin.rb  
ironrubywatin.rb:8: iwebBrowser2 needs to implement shdocvw.IWebBrowser2  
(Argume  
ntError)

Thanks,  
Azam

On Tue, Sep 22, 2009 at 10:10 AM, Shri B.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

IronRuby start the main thread in STA mode as can be seen by this  
command:

c:\>rbx -e “puts System::Threading::Thread.CurrentThread.ApartmentState”

STA

However, new threads are created in MTA mode (the default).

c:\>rbx -e “Thread.new{ puts  
System::Threading::Thread.CurrentThread.ApartmentState }.join”

MTA

I doubt this is the problem as the error messages would be something  
else. For C#, are all dlls next to the C# application exe? Try running  
the IronRuby repro out of bin\Debug to reduce the issues that could  
cause problems. If you cannot get even “require ‘Microsoft.mshtml.dll’”  
to work, then you know its some basic problem unrelated to Watin.

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Mohammad A.  
Sent: Monday, September 21, 2009 7:07 PM

To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

WatiN works in STA (Single Threaded Apartment). Maybe I am missing that?  
How can I create STA threads in IronRuby.

On Mon, Sep 21, 2009 at 7:03 PM, Mohammad A.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

I created a C# application and used WatiN. It worked flawlessly and  
without any configuration. For some reason IronRuby is requiring  
something more to run the application.

On Mon, Sep 21, 2009 at 3:11 PM, Jimmy S.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

You can do “igem install” against any pure-Ruby gem; only gems with  
native extensions require an IronRuby-specific gem. And “igem” is  
nothing more than a bat file to call RubyGems with IronRuby; RubyGems  
for IronRuby is identical to MRI’s version.

That being said, I don’t know what type of dependencies Selenium has.

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Mohammad A.  
Sent: Monday, September 21, 2009 3:03 PM

To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby with WatiN

I will try the Selenium Client gem. But is there any igem install  
selenium-client or do I have to use the Ruby version of Selenium client.

On Mon, Sep 21, 2009 at 2:52 PM, Ivan Porto C.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

## You could try the selenium client gem that may work.

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))

On Mon, Sep 21, 2009 at 11:35 PM, Mohammad A.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

Hi,

Since, Watir is currently not supported I want to check out WatiN with  
IronRuby. Yes, I know I can use it with C# but I am interested in using  
IronRuby. I am getting the following exception:

Here is the code:

require File.dirname( **FILE** ) + ‘/bin/Debug/WatiN.Core.dll’

require File.dirname( **FILE** ) + ‘/bin/Debug/Interop.SHDocVw.dll’

require File.dirname( **FILE** ) + ‘/bin/Debug/Microsoft.mshtml.dll’

IE = WatiN::Core::IE

i = IE.new()

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 14, 2013, 4:37pm UTC](https://www.ruby-forum.com/t/ironruby-with-watin/175887/19 "2013-09-14T16:37:51Z")

</div>

Is this issue resolved?

I am able to work with IronRuby latest version and WatiN latest version.

Here is code script name ironrubywatin.rb

require ‘WatiN.Core’

include WatiN::Core

ie = IE

find = Find

ie.new(‘[www.google.com](http://www.google.com)’)

ie.bring\_to\_front

ie.text\_field(find.by\_name(‘q’)).type\_text(“IronRuby and WatiN”)

ie.button(find.by\_name(“btnG”)).click

ie.close

ie.dispose

use below statement to run the script

ir -S ironrubywatin.rb

The above script works only when all the dll and the script are in same  
location.

WatiN.Core.dll

Interop.SHDocVw.dll

Microsoft.mshtml.dll

ironrubywatin.rb

Thanks and Regards
