Using RemoteWebDriver

332 views
Skip to first unread message

Adam

unread,
Jul 3, 2012, 7:51:50 AM7/3/12
to co...@googlegroups.com
Hey Adrian,

I think I have come across a problem with extending SeleniumWebDriver I have a couple of solutions too.

So heres what I'm running:
 public class AdamsWebdriver :SeleniumWebDriver
    {
 
       
        public AdamsWebdriver(Browser browser)
            : base(new RemoteWebDriver(new Uri(@"http://10.2.2.48:4444/wd/hub"), new DesiredCapabilities("iexplore""9"Platform.CurrentPlatform) { IsJavaScriptEnabled = true }))
        {           
        }
 
        protected AdamsWebdriver(IWebDriver webDriver)
            : base(new RemoteWebDriver(new Uri(@"http://10.2.2.48:4444/wd/hub"), new DesiredCapabilities("iexplore""9"Platform.CurrentPlatform) { IsJavaScriptEnabled = true }))
        {
        }
}

Excuse the silly name, I was jsut testing.  So running this code gives an exception as it doesn't set _browser.  I can't set _browser and using:

 protected new bool NoJavascript
        {
            get { return false; }
        }

does not work because it references the one inside SelniumWebDriver.  I guess there are a couple of options:

1) Make NoJavascript virtual
2) make _browser overridable

If I am using this incorrectly please let me know but to me it looks like the codes evolved to include browser and this doesn't work with overriding the driver.

Thanks

Adam


Adrian Longley

unread,
Jul 3, 2012, 9:43:16 AM7/3/12
to co...@googlegroups.com
No you are quite right. It is a bug.

What was missing was the browser should have been received by the base constructor and set there so with the fix your code will now look like this:

 public class AdamsWebdriver : SeleniumWebDriver
    {    
        public AdamsWebdriver(Browser
 browser)
            : base(new RemoteWebDriver(new Uri(@"http://10.2.2.48:4444/wd/hub"), new DesiredCapabilities("iexplore""9"Platform.CurrentPlatform) { IsJavaScriptEnabled = true }), browser)
        {           
        }
}
This also gives you the option of replacing the configured browser with your own at this point. Since you are fixing it to IE I suppose it might be a good idea to just hard code it to Browser.InternetExplorer in this case.

You never needed the second constructor in any case.

I've opened an issue on github for this and I'll push out a new Coypu soon to fix it.

Thanks for your help
Adrian

Thanks

Adam



Adrian Longley

unread,
Jul 3, 2012, 10:09:14 AM7/3/12
to co...@googlegroups.com
OK, this is fixed in Coypu 0.10.1 which is available from nuget.org now.

Cheers,
Adrian

Adam

unread,
Jul 3, 2012, 12:14:27 PM7/3/12
to co...@googlegroups.com
Hey Adrian,

That is perfect.  Thanks for your speedy response again.  Aside from that getting it to run on a remote machine was relatively painless. 

Regards

Adam

circa.1741

unread,
Mar 26, 2013, 6:48:50 PM3/26/13
to co...@googlegroups.com
May I ask if this is how to use coypu with grid 2?  I am trying to do just that and am looking for some reference.  Thanks.
Reply all
Reply to author
Forward
0 new messages