【发布时间】:2017-10-19 19:20:19
【问题描述】:
我试图使用 POM 将我的定位器的整个定义从标准格式转换为注释 FindsBy。但我有一些定位器,它们由非静态变量组成,我收到错误消息:“无法在静态上下文中访问非静态字段 _createBookData”。
我想得到的代码:
[FindsBy(How = How.CssSelector, Using ="#select-month > option:nth-child(" + _createBookData.NumberMonth + ")") ] private IWebElement BirthmonthDropItem;
代替这段代码:
private IWebElement BirthmonthDropItem
{
get
{
return _waitDriver.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("#select-month > option:nth-child(" + _createBookData.NumberMonth + ")")));
}
}
【问题讨论】:
标签: c# selenium-webdriver annotations pageobjects