我正在尝试使用 Selenium Grid 在 Google Chrome 9.0.597.98 beta 中运行测试。我使用 Selenium Grid 附带的默认 *googlechrome 目标从 C# 启动测试。当我尝试打开网站时,遇到“无法调用未定义的方法'indexOf'”错误。
我发现有人发了一篇帖子,建议解决方案是通过传入一些参数来稍微降低 Chrome 的安全性。 这篇文章建议使用如下内容:
DefaultSelenium selenium = new DefaultSelenium(位置、端口、浏览器、targetPath);
BrowserConfigurationOptions bco = new BrowserConfigurationOptions();
selenium.start(bco.setCommandLineFlags("--disable- web-security"));
由于某种原因,我在任何地方都看不到 BrowserConfigurationOptions
。 这是 Selenium dll 附带的东西吗?它是否在 .NET 版本中不可用,但在其他版本中可用?我需要什么选项来设置这个“--disable-web-security”选项,是否有更好的方法来做到这一点?
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?
发布评论
评论(3)
尝试删除 /
在 ryanhayes.net 修复问题后
Try this
removing the / after the ryanhayes.net fixes the problem
非常感谢,我正在查找此信息,我在这里找到了它!
现在我可以在 googlechrome 中运行我的测试,早些时候我遇到了同样的问题。
以下代码对我有用:
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:
您假设 .Net 没有
BrowserConfigurationOptions
对象是正确的,但幸运的是您不需要它(它只是一个薄包装)。 DefaultSelenium 对Start()
方法有两个重写。其中一个不带任何参数并正常启动浏览器,但另一个带指定浏览器选项的字符串。尝试selenium.Start("--disable-web-security")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 theStart()
method. One of them takes no parameters and starts the browser normally, but the other takes a string specifying browser options. tryselenium.Start("--disable-web-security")