3

I'm trying to run a test in Google Chrome 9.0.597.98 beta using Selenium Grid. I'm firing the test off from C# using the default *googlechrome target that ships with Selenium Grid. When I try to open a site, I'm greeted with a "Cannot call method 'indexOf' of undefined" error.

I've found a post from someone who suggests that the solution is to drop security on Chrome a bit by passing in some parameters. This post suggest using something like this:

DefaultSelenium selenium = new DefaultSelenium(location, port, browser, targetPath);

BrowserConfigurationOptions bco = new BrowserConfigurationOptions();

selenium.start(bco.setCommandLineFlags("--disable-web-security"));

For some reason I don't see the BrowserConfigurationOptions anywhere. Is this something that ships with the Selenium dll? Is it something that's not available in the .NET version, but is in others? What options do I have to setting this "--disable-web-security" option and is there a better way of doing this?

enter image description here

Ryan Hayes
  • 5,290
  • 4
  • 42
  • 52

3 Answers3

1

Try this

[TestInitialize]

public void PreTest()
{
 selenium = new    DefaultSelenium("localhost",4444,"googlechrome","http://www.ryanhayes.net")
}


[TestMethod]

public void TestRyanHayesDotNet()
{
selenium.Open("/")

}

removing the / after the ryanhayes.net fixes the problem

retornam
  • 329
  • 1
  • 8
1

Thanks a lot for this, I was looking this information and I got it here! Now I'm able to run my test in googlechrome, earlier I was getting the same problem.

Following code is working for me:

BrowserConfigurationOptions webSec = new BrowserConfigurationOptions();
selenium.start(webSec.setCommandLineFlags("--disable-web-security"));
Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Dinesh
  • 11
  • 1
0

You're correct in assuming .Net doesn't have BrowserConfigurationOptions object, but fortunately you don't need it (it's only a thin wrapper). DefaultSelenium has two overrides for the Start() method. One of them takes no parameters and starts the browser normally, but the other takes a string specifying browser options. try selenium.Start("--disable-web-security")

pnewhook
  • 4,048
  • 2
  • 31
  • 49
  • Doesn't look like there's an overload for Start for me. I'm running v1.1.4322 of the ThoughtWorks.Selenium.Core.dll. Is there a different one that I need somewhere that contains the overload? – Ryan Hayes Feb 14 '11 at 18:28
  • Found it. I downloaded the Selenium RC version originally, which only had .Start(). I just now got the Selenium WebDriver version, which contains the updated Thoughtworks.Selenium.Core.dll. I added the disable web security option, but I still get the same error message. Must be something else. :-/ – Ryan Hayes Feb 14 '11 at 18:41
  • In C# DefaultSelenium, not ISelenium has the Start with options overload. However, it does not work as advertised. I can avoid the error message by ensuring that all of my work is done on the same domain. In your example, everything would be in http://www.ryanhayes.net – Precipitous Oct 20 '11 at 00:51