如何修复“访问属性“文档”的权限被拒绝”?

发布于 2024-11-24 11:44:49 字数 1555 浏览 0 评论 0原文

在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情域 2024-12-01 11:44:49

有人在 sqa.stackexchange.com

我尝试使用 "*chrome D:\Program Files (x86)\Firefox 4\firefox.exe" ,似乎它正在工作。

引用提到的链接:

这里*chrome指的是firefox浏览器,安全性更高
java 脚本安全限制的权限。

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:

Here *chrome refers to firefox browser and has elevated security
privileges on java script security restrictions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文