在使用selenium进行自动化测试时,我遇到了这个问题。我只是在遵循教程中的步骤。下面是代码(与教程相同):
[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浏览器弹出,url如下所示:
http://www.google.com/selenium-server/core/RemoteRunner.html?sessionId=507c2d6ec7214587984f0f86148e9ff5&multiWindow=true&baseUrl=http%3A%2F%2Fwww.google.com%2F&debugMode=false
我认为url应该是http://localhost:4444,并更改了url (剩下的)。现在打开一个selenium页面(右边是命令)。然后它打开了google页面,但之后就什么都没有了。nunit向我展示了测试用例失败的原因:拒绝访问属性“文档”的权限
有什么想法吗?提前谢谢。
发布于 2011-07-20 04:21:31
有人在sqa.stackexchange.com上回答了
我试过用"*chrome D:\Program Files (x86)\Firefox 4\firefox.exe",它看起来很管用。
引用上述链接的话:
这里的
指的是火狐浏览器,并在java脚本安全限制上提升了安全权限.
https://stackoverflow.com/questions/6742271
复制相似问题