C# 为什么在一个功能文件中使用selenium会出现空引用异常,而在另一个功能文件中使用selenium的代码工作正常
您好,我是C和selenium新手,由于对象引用未设置为对象的实例,我收到了一个错误。我的代码是C# 为什么在一个功能文件中使用selenium会出现空引用异常,而在另一个功能文件中使用selenium的代码工作正常,c#,selenium-webdriver,specflow,C#,Selenium Webdriver,Specflow,您好,我是C和selenium新手,由于对象引用未设置为对象的实例,我收到了一个错误。我的代码是 public LoginPage() : base() { PageFactory.InitElements(Driver, this); } public LoginPage GoTo() { Console.WriteLine(ApplicationbaseURL()); Driver.N
public LoginPage()
: base()
{
PageFactory.InitElements(Driver, this);
}
public LoginPage GoTo()
{
Console.WriteLine(ApplicationbaseURL());
Driver.Navigate().GoToUrl(ApplicationbaseURL());
try
{
if (this.IsCurrentPage() == false)
{
throw new WebDriverException("Not on correct Page");
}
}
catch (WebDriverException ex)
{
Console.WriteLine("Exception caught: {0}", ex);
}
return this;
}
确保在基类中不使用析构函数!
如果基类中有析构函数,则可以随时调用它,因此不存在驱动程序。在哪一行发生异常?它是哪个对象?驱动程序、导航、PageFactory?可能与