如何使用 page object 模式断言页面标题 Selenium C#

How to assert the page title using page object pattern Selenium C#

我正在使用带有 Selenium C# 和 MSTest 的页面 Object 模式,我想通过使用实际页面标题断言预期的页面标题来断言我已经到达了正确的页面。我有以下代码,但它不起作用:

框架:

public class MyAccountPage
{
public const string MyAccountPageTitle = "My Account";

public static bool IsAt()
{
return Driver.Instance.Title == MyAccountPageTitle;
}

测试:

Assert.IsTrue(MyAccountPage.IsAt);

IsAt 是一个 方法 - 调用它:

Assert.IsTrue(MyAccountPage.IsAt());