I got warning message in Visual Studio 2010 : “Field is never assigned”.
I use Webdriver PageFactory that assigned field in runtime, how can i suppress this message?
here is sample of code:
public class VideoInfo
{
[FindsBy(How = How.ClassName, Using = "detailsTitle")]
private IWebElement _videoInfoDetailsTitle; //Here is got the warning message
public VideoInfo(IWebDriver webDriver)
{
PageFactory.InitElements(webDriver, this); //Assigen the field
}
}
Since there’s some voodoo going on that the compiler can’t detect; you can just ignore the warning. However, it’s perhaps better to initialise the field explicitly: