I was working in a selenium project in the cs codebehind for an aspx page but have been trying to transfer my code to an nunit testfixture class. in a class library project. The code below ran without issues in my original cs page, but now I get errors like: ‘LibraryTests.Tests.Driver is a field but is used as a type’, ‘a field initializer cannot reference a non-static field, method, or property ‘LibraryTests.Tests.Driver” and that methods such as GoToURL must have a return type.
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl(urlString);
IWebElement name = driver.FindElement(By.Id("UserName"));
IWebElement button = driver.FindElement(By.ClassName("sign in"));
I want to be able to execute the code above before running any tests for efficiency reasons. How do I make this code work in a testfixture class?
I think you want to put the code into a TestFixtureSetup method: