我想添加一个静态字符串属性来跟踪当前运行的测试名称。我认为最好的方法是使用WebDriver,因为它是贯穿所有页面对象的唯一对象。
有没有办法扩展WebDriver类以添加可以设置的字符串属性呢?
编辑:由于WebDriver使用IWebDriver接口,因此我应该扩展接口吗?
编辑#2:添加我目前加载WebDriver的示例:
有没有办法扩展WebDriver类以添加可以设置的字符串属性呢?
编辑:由于WebDriver使用IWebDriver接口,因此我应该扩展接口吗?
编辑#2:添加我目前加载WebDriver的示例:
protected static NLog.Logger _logger = LogManager.GetCurrentClassLogger();
protected static IWebDriver _driver;
/// <summary>
/// Spins up an instance of FireFox webdriver which controls the browser using a
/// FireFox plugin using a stripped down FireFox Profile.
/// </summary>
protected static void LoadDriver()
{
ChromeOptions options = new ChromeOptions();
try
{
var profile = new FirefoxProfile();
profile.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream doc xls pdf txt");
_driver = new FirefoxDriver(profile);
_driver.Navigate().GoToUrl("http://portal.test-web01.lbmx.com/login?redirect=%2f");
}
catch(Exception e)
{
Console.WriteLine(e.Message);
throw;
}
}