我已经使用Selenium和页面对象模型模式进行了大量测试。我试图通过一个By
,所以我可以通过其名称访问元素。然而在我的PageFactory.InitElements(excelSession, ribbon);
方法中,我得到了一个例外Type of member 'By' is not IWebElement or IList<IWebElement>
。有没有办法让这种方法接受By
?成员类型'By'不是IWebElement或IList <IWebElement>
我的代码如下
public class ExcelRibbon
{
[FindsBy(How = How.Name, Using = "Create")]
[CacheLookup]
public By Create { get; set; }
}
当我收到我的错误
public static ExcelRibbon ribbon = new ExcelRibbon();
PageFactory.InitElements(excelSession, ribbon);
webDriverWait.Until(ExpectedConditions.ElementExists(ribbon.Create));
webDriverWait.Until(ExpectedConditions.ElementToBeClickable(excelSession.FindElement(ribbon.Create))).Click();
堆栈跟踪
在 OpenQA.Selenium.Support.PageObjects.DefaultPageObjectMemberDecorator.CreateProxyObject(类型 memberType,IElementLocator定位器,IEnumerabl e`1查探,布尔 缓存)
添加的错误跟踪问题 –
@ShubhamJain我添加了一个stackTrace –