I’m using specflow and want a Repo to store all my xpaths to make it cleaner and easier to undertsand. So the Repo I have is
using OpenQA.Selenium;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SpecFlowProject1.Repository
{
public class Repository
{
public static By AcceptCookies = By.XPath(".//button[@id='onetrust-accept-btn-handler']");
}
}
And within the step definition file I have tried to click the element with the following commands
[Given(@"Navigate to morrisons")]
public void GivenNavigateToMorrisons()
{
driver.Url = ("https://morrisons.com");
//Accept cookies
driver.FindElement(AcceptCookies).Click();
}
The error it gives is the name AccceptCookies does not exist in this current context
I’ve tried importing the Repository class but that doesn’t work. What am I missing here?
Thanks