Lets say I have a page object
[FindsBy(How = How.Id, Using = "buttonSignIn")]
public IWebElement BtnSignin { get; set; }
I am trying to pass that into this method to convert the IWebElement
into a By
element.
public void MoveAndClick(IWebElement element)
{
var findElement = driver.FindElement((By)element);
Actions act = new Actions(driver);
act.MoveToElement(findElement);
act.Click(findElement);
act.Perform();
}
I know that this piece of code will work without casting the element into a By
element, however for my tests to work I need to figure out how to convert the IWebElement
into a By
element.
When I run this I get a null exception error. Does anyone have a simple solution for this?