System.TypeLoadException in Coypu.Drivers.WatIn.WatiNDriver

55 views
Skip to first unread message

joão marcos Jardim

unread,
Mar 17, 2015, 2:26:22 PM3/17/15
to co...@googlegroups.com
HI,

I'm trying to use the WatIn driver for Coypu, but with no success. In my test, I have a combobox for choosing the browser.
Then, when user clicks a button checks if Internet Explorer is selected as the browser and sets the corresponding driver.

Here's my code for the click event on button:

private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == 0)
                sessionConfiguration = new SessionConfiguration() { Driver = typeof(Coypu.Drivers.Watin.WatiNDriver) };
            else
                sessionConfiguration = new SessionConfiguration() { Driver = typeof(Coypu.Drivers.Selenium.SeleniumWebDriver) };

            switch (comboBox1.SelectedIndex)
            {
                case 0: sessionConfiguration.Browser = Coypu.Drivers.Browser.InternetExplorer; break;
                case 1: sessionConfiguration.Browser = Coypu.Drivers.Browser.Firefox; break;
                case 2: sessionConfiguration.Browser = Coypu.Drivers.Browser.Chrome; break;
            }

            if (Processados == null)
                Processados = new List<Dadostabela>();
            if (Rejeitados == null)
                Rejeitados = new List<Dadostabela>();
            Processados.Clear();
            Rejeitados.Clear();
            ConsultaProtocoloRVSRAS();
            ConsultaProtocoloRFRP();
            if (browserSession != null)
            {
                browserSession.Dispose();
                browserSession = null;
            }
        }

But when I click this button, the application breaks with System.TypeLoadException, the message is in portuguese, it tells that the method ExcuteScript of type Coypu.Drivers.WatIn.WatiNDriver does not have an implemntation.
Also, this is the line where app breaks, on main():

Application.Run(new Form1());

So i'm guessing the error ocurrs on loading the Coypu.WatIn assembly. Now, what I have to do to get this to work???

Thanks

joão marcos Jardim

unread,
Mar 19, 2015, 5:13:10 PM3/19/15
to co...@googlegroups.com
I  had to clone the coypu repository and build the assembiles.
Only then it worked.

Unfortunately, watin dont work as expected with the coypu watin driver. For example, if you want to select a option in a select list you better call a javascript to do this or else the driver will raise a InvalidCast exception.

Another thing is trying to use the FindWindow() method, it doesn't work on watin driver!!

I wish I could try and understand the source code for the driver to make the appropriate change, but untiil then I will try to use as is. 

joão marcos Jardim

unread,
Mar 20, 2015, 8:58:32 PM3/20/15
to co...@googlegroups.com
For anyone having trouble with WatiN SelectLists:

Use the Native property of BrowserSession class to convert to Coypu.Drivers.Watin.IEWithDialogWaiter, then you can properly search for the selectlist you want and select the option.

var sistema = ((Coypu.Drivers.Watin.IEWithDialogWaiter)browserSession.Native).SelectList(WatiN.Core.Find.ByName("sistema"));
sistema.Options[1].Select();

PS: I really want to add support for the SelectOption operation on the WatiN driver, but I guess I'm too unexperienced or it's really hard to understand how Coypu and the WatiN driver works
Reply all
Reply to author
Forward
0 new messages