我正在使用Selenium v3.6.0和.NET Core 2.0,以下代码在PageFactory.InitElements上给我一个错误,说它不存在于当前上下文中。
using OpenQA.Selenium;
using OpenQA.Selenium.Support.PageObjects;
namespace Example
{
public class Form
{
[FindsBy(How = How.Name, Using = "Filter")] // This does exist in current context using .NET Core
public IWebElement Filter { get; set; }
[FindsBy(How = How.TagName, Using = "Button")]
public IWebElement Button;
public Form(IWebDriver driver)
{
PageFactory.InitElements(driver, this); // This doesn't exist in current context using .NET Core
}
}
}
我有点困惑,因为FindsBy、FindsByAll和FindsBySequence这些属性都在 OpenQa.Selenium.Support.PageObjects
命名空间中可用,但是PageFactory却不可用。据我所知,这些属性仅适用于PageFactory。
在.NET Core中是否有不同的方法,或者它只是尚未实现?