嗨,我是C#和selenium的新手,由于对象引用未设置为对象实例,我遇到了错误。我的代码是
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;
}
确保基类中没有使用析构函数!如果你的基类中有析构函数,它可以随时调用,所以你没有驱动程序。