如何解决“拒绝访问属性'document'的权限"? [英] How to fix "Permission denied to access property 'document'"?

查看:493
本文介绍了如何解决“拒绝访问属性'document'的权限"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试使用硒rc自动进行测试时,我遇到了这个问题.我只是按照教程中的步骤进行操作.这是代码(与教程相同):

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);
        }
    }
}

运行测试时,我的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

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

我认为该网址应为 http://localhost:4444 ,并更改了该网址(其余部分保留了).现在,将打开一个硒页面(右侧带有命令).然后,它会打开google页面,但此后什么也没有. nunit告诉我测试用例失败,并说明原因:拒绝访问属性'document'的权限

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.

推荐答案

有人在我尝试过使用"*chrome D:\Program Files (x86)\Firefox 4\firefox.exe",并且似乎可以正常工作.

I tried with "*chrome D:\Program Files (x86)\Firefox 4\firefox.exe" and seems it is working.

引用提到的链接:

此处*chrome是指Firefox浏览器,具有较高的安全性 Java脚本安全性限制的特权.

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

这篇关于如何解决“拒绝访问属性'document'的权限"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆