I have created my selenium tests however I would like to start cleaning them up for readability and reuse. What do you do with your variables?
I have thought about setting up some kind of dictionary of buttons that could be looked up but think that may cause more problems than solve.
[Test]
public static void TestAccrualRuleSet()
{
//Setup buttons and variables
IWebDriver driver = new ChromeDriver();
var hamburgerMenu = By.XPath("//*[@id='menu-toggle']/span/i");
var settingsMenuButton = By.XPath("//*[@id='ulAdminNavBar']/li[4]/a");
var timeAndLaborMgmtButton = By.XPath("//*[@id='ulAdminNavBar']/li[4]/ul/li[11]/a");
var timeOffTrackingButton = By.XPath("//*[@id='ulAdminNavBar']/li[4]/ul/li[11]/ul/li[2]/a");
var actionMenu = By.Id("ucAccrualRules_ddlAccrual");
var ruleNameTextBox = By.Id("ucAccrualRules_ucAccrualRule_txtRuleName");
var accrualRuleFrequencyDropDown = By.Id("ucAccrualRules_ucAccrualRule_cboAccrualType");
var dropDownAccrualTypes = By.Id("ucAccrualRules_ucAccrualRule_hourTypes");
var dropDownAccrualTypesCheckBox1 = By.Id("ucAccrualRules_ucAccrualRule_hourTypes_0");
var dropDownAccrualTypesCheckBox2 = By.Id("ctl00_ContentPlaceHolder1_ucAccrualRules_ucAccrualRule_hourTypes_1");
var dropDownAccrualTypesCheckBox3 = By.Id("ctl00_ContentPlaceHolder1_ucAccrualRules_ucAccrualRule_hourTypes_6");
var maxCarryForwardTextBox = By.Id("ctl00_ContentPlaceHolder1_ucAccrualRules_ucAccrualRule_txtMaxRollover");
var accrualWaitingTextBox = By.Id("ctl00_ContentPlaceHolder1_ucAccrualRules_ucAccrualRule_txtAccrualWaitingPeriod");
var saveButton = By.XPath("//*[@id='ctl00_ContentPlaceHolder1_ucAccrualRules_ucAccrualRule_cmdUpdateName']");
var savedSuccessfully = By.Id("ctl00_ContentPlaceHolder1_ucAccrualRules_ucAccrualRule_UCErrorRuleProperties_lblMessage");
var propertiesButton = By.Id("ctl00_ContentPlaceHolder1_ucAccrualRules_ucAccrualRule_tpAccuralRulePropertiesnewForms");
IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
//Begin test
AppExtensions.LoginUsingChrome(driver);
AppExtensions.SelectCompany(driver, "Ren's Test Account");
System.Threading.Thread.Sleep(1500);
WebDriverExtensions.Element_Click(driver, hamburgerMenu);
System.Threading.Thread.Sleep(1500);
While this is not the whole test, it shows you an example of my huge list of variables I am using to store the buttons/links I need to perform my test. What is best practice regarding how and where these variables are stored for Selenium tests?