的一個實例,當我在NUnit的運行這個程序,我得到一個錯誤對象引用未設置到對象
對象引用不設置到對象的實例。
儘管這不是原始程序,但我也得到了類似的錯誤。任何幫助讚賞。異常發生在
driver.Navigate().GoToUrl("http://www.yahoo.com/");
計劃:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;
namespace Class_and_object
{
[TestFixture]
public class Class1
{
IWebDriver driver = null;
[Test]
public void test1()
{
class2 obj = new class2();
driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.google.com/");
obj.method();
}
}
public class class2
{
IWebDriver driver = null;
public void method()
{
driver.Navigate().GoToUrl("http://www.yahoo.com/");
}
}
}
在class2 method()中忘記'driver = new FirefoxDriver();'? – rene
將來,當您編寫涉及異常的問題時,請向我們顯示*發生異常的位置。 –