如何修复“访问属性“文档”的权限被拒绝”?
在尝试使用 selenium rc 进行自动化测试时,我遇到了这个问题。我只是按照教程中的步骤进行操作。这是代码(与教程相同):
[TestFixture]
public class SeleniumTest
{
private ISelenium selenium;
private StringBuilder verificationErrors;
[SetUp]
public void SetupTest()
{
selenium = new DefaultSelenium("localhost", 4444, @"*custom D:\Program Files (x86)\Firefox 4\firefox.exe", "http://www.google.com/");
selenium.Start();
verificationErrors = new StringBuilder();
}
[TearDown]
public void TeardownTest()
{
try
{
selenium.Stop();
}
catch (Exception)
{
// Ignore errors if unable to close the browser
}
Assert.AreEqual("", verificationErrors.ToString());
}
[Test]
public void TheGoogleTest()
{
selenium.Open("/");
selenium.Type("lst-ib", "selenium");
try
{
Assert.IsTrue(selenium.IsTextPresent("Selenium - Web Browser Automation"));
}
catch (AssertionException e)
{
verificationErrors.Append(e.Message);
}
}
}
当我运行测试时,我的 firefox-5 浏览器会弹出,网址如下所示:
http://www.google.com/selenium-server/core/RemoteRunner.html?sessionId=507c2d6ec7214587984f0f86148e9ff5&multiWindow=true&baseUrl=http%3A%2F%2Fwww.google.com%2F&debugMode=false
我认为网址应该是http://localhost:4444 并更改了 url(保留其余部分)。现在将打开一个 selenium 页面(右侧有命令)。然后它会打开谷歌页面,但此后什么也没有。 nunit 向我显示测试用例失败,并说明原因:访问属性“文档”的权限被拒绝
知道吗?提前致谢。
While trying to automate testing with selenium rc I ran into this problem. I was just following the steps in the tutorials. Here is the code (same as tutorials):
[TestFixture]
public class SeleniumTest
{
private ISelenium selenium;
private StringBuilder verificationErrors;
[SetUp]
public void SetupTest()
{
selenium = new DefaultSelenium("localhost", 4444, @"*custom D:\Program Files (x86)\Firefox 4\firefox.exe", "http://www.google.com/");
selenium.Start();
verificationErrors = new StringBuilder();
}
[TearDown]
public void TeardownTest()
{
try
{
selenium.Stop();
}
catch (Exception)
{
// Ignore errors if unable to close the browser
}
Assert.AreEqual("", verificationErrors.ToString());
}
[Test]
public void TheGoogleTest()
{
selenium.Open("/");
selenium.Type("lst-ib", "selenium");
try
{
Assert.IsTrue(selenium.IsTextPresent("Selenium - Web Browser Automation"));
}
catch (AssertionException e)
{
verificationErrors.Append(e.Message);
}
}
}
When I run the test, my firefox-5 browser pops up and the url looks like this:
http://www.google.com/selenium-server/core/RemoteRunner.html?sessionId=507c2d6ec7214587984f0f86148e9ff5&multiWindow=true&baseUrl=http%3A%2F%2Fwww.google.com%2F&debugMode=false
I thought the url should be http://localhost:4444 and changed the url (leaving the rest). Now a selenium page opens up (with commands on the right). It then opens the google page, but nothing after that. And nunit shows me the test case failed, stating the reason: Permission denied to access property 'document'
Any idea? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有人在 sqa.stackexchange.com:
我尝试使用
"*chrome D:\Program Files (x86)\Firefox 4\firefox.exe"
,似乎它正在工作。引用提到的链接:
Someone answered it on sqa.stackexchange.com:
I tried with
"*chrome D:\Program Files (x86)\Firefox 4\firefox.exe"
and seems it is working.Quote from the link mentioned: