private bool WaitUntil(tstObject tstObj, string inPath, out string outString, out TimeSpan elapsedTime, string objVis)
        {
            Stopwatch stopwatch;
                bool objPres;
                outString = "";
                objPres = false;

                stopwatch = new Stopwatch();

                //start a stopwatch. This will break out after 6 seconds of looking
                stopwatch.Start();
                do
                {
                    //check to see if an object is present on the screen
                    objPres = tstObj.IsElementPresent(By.XPath(inPath));

                    elapsedTime = stopwatch.Elapsed;

                    if (elapsedTime.Seconds >= 6)
                    {
                        //check to see if the object is not supposed to be present
                        if (objVis == "N")
                        {
                            objPres = true;
                        }
                        else
                        {
                            //set objPres to false and send an error message back to the calling function
                            objPres = false;
                            outString = "ERROR: The object was not found after six seconds \r\n" + inPath;
                        }

                        break;
                    }

                } while (objPres != true);

                //stop the stopwatch
                stopwatch.Stop();

                //send objPres back to the calling function
                return objPres;
        }
        public void vfyTableEntry(tstObject tstObj, string tblPath, string xpath, string schCol, string mvCol, string vfySegment, string offsetItem,
                string getNeg, string isHeader, string thsTable, string schItem, string datsource, string stpNum, string pth, ref string retXpath, ref string[,]rsltArray, out int fndExcep, out int tstFail)
        {
            bool objPres;
                string tblEntry;
                string fndPath;
                string schPath;
                int numRows;
                int fndItem;

                fndPath = "";
                objPres = false;
                tblEntry = "";
                numRows = 0;
                fndItem = 0;
                tstFail = 0;
                fndExcep = 0;

                try
                {
                    //get the table Entry...this may need to be gleaned from the table entry using Firebug as there may very well be other
                    //things present (exclamation point, pencil icon, etc.) which may changer the text present
                    objPres = tstObj.IsElementPresent(By.XPath(tblPath));

                    if (fndItem == 0)
                        fndItem = 0;

                    //no need to get the number of rows unless the object is present
                    if (objPres == true)
                    {
                        numRows = driver.FindElements(By.XPath(tblPath + xpath)).Count;

                        if (numRows > 0)
                        {
                            for (int x = 1; x <= numRows; x++)
                            {
                                //check for a header item in the table and append /th tags
                                if (isHeader == "Y")
                                {
                                    if (x == 1)
                                    {
                                        tblEntry = driver.FindElement(By.XPath(tblPath + xpath + "/th[" + schCol + "]")).Text;
                                    }
                                    else
                                    {
                                        tblEntry = driver.FindElement(By.XPath(tblPath + xpath + "[" + x.ToString() + "]/th[" + schCol + "]")).Text;
                                    }
                                }
                                //if not a header append standard /tr (table row) tags
                                else
                                {
                                    if (x == 1)
                                    {
                                        //initial row condition. Straight copy of xpath variable
                                        if (schCol == "1")
                                        {
                                            fndPath = tblPath + xpath + "/td";
                                            tblEntry = driver.FindElement(By.XPath(fndPath)).Text;
                                        }
                                        else
                                        {
                                            fndPath = tblPath + xpath + "/td[" + schCol + "]";
                                            tblEntry = driver.FindElement(By.XPath(fndPath)).Text;
                                        }
                                    }
                                    else
                                    {
                                        if (schCol == "1")
                                        {
                                            //subsequent row condition. Append an index [x] to the xpath
                                            fndPath = tblPath + xpath + "[" + x.ToString() + "]/td";
                                            tblEntry = driver.FindElement(By.XPath(fndPath)).Text;
                                        }
                                        else
                                        {
                                            //subsequent row condition. Append an index [x] to the xpath
                                            fndPath = tblPath + xpath + "[" + x.ToString() + "]/td[" + schCol + "]";
                                            tblEntry = driver.FindElement(By.XPath(fndPath)).Text;
                                        }
                                    }
                                }

                                if (datsource == "EX" && vfySegment != "Y")
                                {
                                    tblEntry = TestSuite.setSlash(tblEntry);
                                }
                                //construct the search string using the x variable (row position) and the schCol variable (column position) to isolate
                                //the cell text to search
                                else if (vfySegment == "Y")
                                {
                                    //if the search column is the first coliumn
                                    if (schCol != "1")
                                    {
                                        //if the current row position is the first row
                                        if (x == 1)
                                        {
                                            schPath = xpath + "/td[" + schCol + "]";
                                        }
                                        //if the current is not the first row, asppend the rownumnber on the tr tag of xpath
                                        else
                                        {
                                            schPath = xpath + "[" + x.ToString() + "]/td[" + schCol + "]";
                                        }
                                    }
                                    else
                                    {
                                        //if the current row position is the first row
                                        if (x == 1)
                                        {
                                            schPath = xpath + "/td";
                                        }
                                        //if the current is not the first row, asppend the rownumnber on the tr tag of xpath
                                        else
                                        {
                                            schPath = xpath + "[" + x.ToString() + "]/td";
                                        }
                                    }

                                    //send the search path (tblPath to the table -- xpath to isolate the cell in the table) to extract the table entry
                                    tblEntry = TestSuite.getTableEntry(driver, tblPath, tblEntry.Trim(), schItem, schPath, schItem.Length);
                                }

                                //enter into this
                                if (tblEntry.Trim() == schItem)
                                {
                                    if (mvCol == "Y")
                                    {
                                        retXpath = fndPath;
                                        break;
                                    }

                                    if (Convert.ToInt32(mvCol) >= 1)
                                    {
                                        tblEntry = driver.FindElement(By.XPath(tblPath + xpath + "[" + x.ToString() + "]/td[" +
                                            (Convert.ToInt32(schCol) + Convert.ToInt32(mvCol)).ToString() + "]")).Text;
                                    }
                                    else
                                    {
                                        offsetItem = schItem;
                                    }

                                    if (offsetItem == tblEntry.Trim() && offsetItem != "NOT BLANK")
                                    {
                                        //write to results file that item was found in the offset column
                                        objPres = true;
                                        fndItem = 1;
                                        break;
                                    }
                                    else if (offsetItem == "NOT BLANK" && tblEntry.Trim() != "")
                                    {
                                        //write to results file that item was found in the offset column
                                        objPres = true;
                                        fndItem = 1;
                                        break;
                                    }
                                    else
                                    {
                                        //set  objPres to false and keep scrolling if offset item doesn't match
                                        objPres = false;
                                        tstFail = -1;
                                        fndItem = 0;
                                        break;
                                    }
                                }
                                else
                                {
                                    if (x == numRows)
                                    {
                                        //if the item  is supposed to be on the screen, but is not set the testfail variable to log the failed test
                                        //if getNeg is 'N' and the item is not present, set  variables to show this
                                        if (getNeg == "N")
                                        {
                                            fndItem = 0;
                                            objPres = false;
                                        }
                                        else
                                        {
                                            objPres = false;
                                            tstFail = -1;
                                        }
                                    }

                                }
                            }
                        }
                        else
                        {
                            if (getNeg == "N")
                            {
                                objPres = false;
                                fndItem = 0;
                            }
                            else
                            {
                                objPres = true;
                                tstFail = -1;
                            }
                        }
                    }
                    else
                    {
                        if (getNeg == "N")
                        {
                            fndItem = 0;
                        }
                        else
                        {
                            fndItem = 1;
                            tstFail = -1;
                        }

                    }
                }
                catch (Exception e)
                {
                    TextFileOps.Write(pth, e.Message, -1);

                    fndExcep = -1;
                }

                //if there is no offset on the table then use schItem to record results
                //if mvCol is > 0 then ise the offsetItem
                if (mvCol != "Y")
                {
                    //a negative result (field not expected) will probably result in a null value
                    //set mvCol = 0 to process if this is the case
                    if (mvCol == "")
                        mvCol = "0";
                    if (Convert.ToInt32(mvCol) == 0)
                    {
                        rsltArray = arrayAppend("verify", "table", objPres.ToString(), schItem.Trim(), schItem.Trim(), thsTable, String.Empty, String.Empty, String.Empty, rsltArray);
                    }
                    else
                    {
                        rsltArray = arrayAppend("verify", "table", objPres.ToString(), tblEntry.Trim(), offsetItem, thsTable, String.Empty, String.Empty, String.Empty, rsltArray);
                    }
                }
        }
        public void vfyObject(tstObject tstObj, string itmPath, string suffix, string getNeg, string lstVerify, string fldName,
                string fldType, bool objPres, string stpNum, string pth, ref string[,] rsltArray, out int fndExcep, out int tstFail)
        {
            string vfyString;
                tstFail = 0;
                fndExcep = 0;
                vfyString = "";

                switch (fldType.Trim())
                {
                    case "dropdown":
                        if (getNeg != "N")
                        {
                            vfyString = driver.FindElement(By.XPath(itmPath)).Text;
                        }

                        objPres = objVerify(vfyString, fldName, getNeg, ref tstFail);

                        rsltArray = arrayAppend("verify", "dropdown", objPres.ToString(), fldName.Trim(), vfyString, lstVerify, String.Empty, String.Empty, String.Empty, rsltArray);
                        break;
                    case "field":
                        fldType = suffix;
                        switch (fldType)
                        {
                            case "Text":
                            {
                                vfyString = driver.FindElement(By.XPath(itmPath)).Text;

                                objPres = objVerify(vfyString, fldName, getNeg, ref tstFail);

                                rsltArray = arrayAppend("verify", "field text", objPres.ToString(), fldName.Trim(), vfyString, lstVerify, String.Empty, String.Empty, String.Empty, rsltArray);

                                break;
                            }
                            default:
                            {
                                break;
                            }

                        }
                        break;
                    case "text":
                        if (getNeg != "N")
                        {
                            vfyString = driver.FindElement(By.XPath(itmPath)).Text;
                        }

                        vfyString = TestSuite.getTableEntry(driver, itmPath, vfyString.Trim(), fldName, "", fldName.Length);

                        objPres = objVerify(vfyString, fldName, getNeg, ref tstFail);

                        rsltArray = arrayAppend("verify", "text", objPres.ToString(), lstVerify, vfyString, fldName.Trim(), String.Empty, String.Empty, String.Empty, rsltArray);
                        break;
                    case "button":
                        if (getNeg != "N")
                        {
                            if (fldName != "Add Outcome")
                            {
                                vfyString = driver.FindElement(By.XPath(itmPath)).Text;
                                objPres = objVerify(vfyString, fldName, getNeg, ref tstFail);
                            }
                            else
                            {
                                vfyString = "Add Outcome";

                                if ((driver.FindElement(By.XPath(itmPath)).Enabled == true && getNeg != "N") || (driver.FindElement(By.XPath(itmPath)).Enabled == false && getNeg == "N"))
                                {
                                    objPres = true;
                                    tstFail = 0;
                                }
                                else
                                {
                                    objPres = false;
                                    tstFail = 0;
                                }
                            }
                        }
                        else
                        {
                            vfyString = fldName;
                            objPres = tstObj.IsElementPresent(By.XPath(itmPath));
                        }

                        rsltArray = arrayAppend("verify", "button", objPres.ToString(), fldName.Trim(), vfyString, lstVerify, String.Empty, String.Empty, String.Empty, rsltArray);
                        break;
                    case "link":
                        if (getNeg != "N")
                        {
                            vfyString = driver.FindElement(By.XPath(itmPath)).Text;
                        }

                        objPres = objVerify(vfyString, fldName, getNeg, ref tstFail);

                        rsltArray = arrayAppend("verify", "link", objPres.ToString(), lstVerify, vfyString, fldName.Trim(), String.Empty, String.Empty, String.Empty, rsltArray);
                        break;
                    case "image":
                        objPres = tstObj.IsElementPresent(By.ClassName(fldName));

                        rsltArray = arrayAppend("verify", "image", objPres.ToString(), fldName.Trim(), lstVerify, String.Empty, String.Empty, String.Empty, String.Empty, rsltArray);
                        break;
                }
        }
        public void tblSelect(tstObject tstObj, bool objPres, string[] inArray, string stpNum, string pth, ref string[,] tstresult, out int fndExcep)
        {
            //inArray contains all the data that has been imported from the spreadsheet. The data will parcelecd out
                //and placed into the respective values that each item corresponds to

                bool lstPath;
                bool gpPres;
                int fndItem;
                int itmCount;
                int numRows;
                int trim;
                int strLen;
                int tblMove;
                string chkMod;
                string frmMod;
                string tblNav;
                string rowText;
                string fndPath;
                //string tagName;
                string tblId;
                string tblName;
                string tblTag;
                string tmpCount;
                string tmpString;
                string txtPath;
                string schCol;
                string schText;
                string slct;
                string suffix;
                string vfyString;
                string vis;
                Boolean found;

                found = false;
                lstPath = false;

                fndExcep = 0;
                fndItem = 0;
                strLen = 0;
                chkMod = "";
                fndPath = "";
                frmMod = "";
                rowText = "";
                schCol = "";
                schText = "";
                tblId = "";
                tblMove = 0;
                tblName = "";
                tblNav = "";
                tblTag = "";
                suffix = "";
                slct = "";
                vis = "";

                //assign variables from passed inArray
                try
                {
                    /*enter into the if portion if inArray[1] is not equal to 'CU'
                    'CU' denotes selecting an item in a cleanup operation and so the table location
                    data needed and will need to be set in the else portion instead of being passed*/
                    /*the if section will take the data passed in from inArray and set it to local variables
                    that the tblSelect function can use*/
                    if (inArray[1] != "CU")
                    {
                        for (int x = 0; x < inArray.Length; x++)
                        {
                            if (inArray[x] != "")
                            {
                                switch (x)
                                {
                                    case 0:
                                        //the xpath down to the table level. Should end in /table
                                        //the /tr, /td, and indexes in the xpath items will be appended
                                        //by the application. the suffix variable will be appended
                                        //to complete the xpath
                                        tblId = inArray[x];
                                        break;
                                    case 1:
                                        //the text being searched for
                                        schText = inArray[x];
                                        break;
                                    case 2:
                                        //the name of the table. Usually the window the table resides in. Used for result
                                        tblName = inArray[x];
                                        break;
                                    case 3:
                                        //the column of the table being searched
                                        schCol = inArray[x];
                                        break;
                                    case 4:
                                        //the column of the found row that an action will take place on
                                        tblNav = inArray[x];
                                        break;
                                    case 5:
                                        //check if a table is located in a modal window
                                        chkMod = inArray[x];
                                        break;
                                    case 6:
                                        //the id of the modal window
                                        frmMod = inArray[x];
                                        break;
                                    case 7:
                                        //additional string to perform an action
                                        suffix = inArray[x];
                                        if (suffix == "N/A")
                                            suffix = "";
                                        break;
                                    case 8:
                                        //
                                        trim = TestSuite.trimString(tblId);
                                        if (inArray[x] != "Y")
                                            lstPath = false;
                                        else
                                            lstPath = true;
                                        break;
                                    case 9:
                                        //variable regualating whether or not a value will be selected of verified
                                        slct = inArray[x];
                                        if (slct == "X")
                                            vis = "N";
                                        else if (slct.Length < 3)
                                        {
                                            vis = "Y";
                                            slct = slct.Substring(0, 1);
                                        }
                                        else
                                        {
                                            vis = slct.Substring(2, 1);
                                            slct = slct.Substring(0, 1);
                                        }
                                        break;
                                }
                            }
                        }
                    }
                    else
                    {
                        switch (inArray[3])
                        {
                            case "Home":
                            case "Courses":
                            {
                                //set all of the location and function variables to select desired item in the table being searched
                                tblId = inArray[2];
                                schText = inArray[0];
                                tblName = inArray[3];
                                schCol = "1";
                                tblNav = "0";
                                chkMod = "";
                                frmMod = "";
                                suffix = "/a";
                                lstPath = false;
                                slct = "Y";

                                break;
                            }
                            case "Events":
                            {
                                break;
                            }
                            case "Grades":
                            {
                                break;
                            }
                            case "Groups":
                            {
                                //set all of the location and function variables to select desired item in the table being searched
                                tblId = inArray[2];
                                schText = inArray[0];
                                tblName = inArray[3];
                                schCol = "1";
                                tblNav = "4";
                                chkMod = "";
                                frmMod = "";
                                suffix = "/div/a";
                                lstPath = false;
                                slct = "Y";
                                break;
                            }
                            case "People":
                            {
                                break;
                            }
                            case "Library":
                            {
                                break;
                            }
                            case "Tools":
                            {
                                break;
                            }
                            default:
                            {
                                break;
                            }
                        }
                    }

                    //set the vfyString if verifying a particular entry in a table
                    if (inArray.Length == 11)
                    {
                        vfyString = inArray[10];
                    }
                    else
                    {
                        vfyString = "";
                    }

                    //set strLen to the search text length. This will be used in case of any suffix
                    //entries in  the searched column
                    strLen = schText.Length;

                    //get number of pages in the table
                    if (lstPath == true)
                    {
                        //get the number of pages in the table if lstPath has a value
                        //Click on the 'last>>' link to go to the last table page
                        driver.FindElement(By.LinkText("last »")).Click();

                        //extract the string value of the last page number
                        tmpCount = driver.FindElement(By.ClassName("pager-current")).Text;

                        //convert to an int for use on a for loop
                        itmCount = Convert.ToInt32(tmpCount);

                        //click on the '<<first' link to return to the first page
                        driver.FindElement(By.LinkText("« first")).Click();

                        //if there are less than three list items, set the itmCount variable == 3
                        if (itmCount < 3)
                        {
                            itmCount = 3;
                        }
                    }
                    else
                    {
                        //set lstpath to 3. When processing 2 is subtracted to account for non-numerical links
                        //in the page list (next>>, <<previous, etc.)
                        itmCount = 3;
                    }

                    //Convert the loaded tblNav string variable to the tblMove integer
                    if (tblNav != "")
                        tblMove = Convert.ToInt32(tblNav);

                    //Check for modal input. If no modal input stop app for 1 sec
                    if (chkMod == "Y")
                    {
                        //switch frame
                        driver.SwitchTo().DefaultContent();
                        driver.SwitchTo().Frame(frmMod);
                        Thread.Sleep(750);
                    }

                    if (tblTag != "")
                    {
                        tblId = tblId + tblTag;

                        //check to see that the table exists
                        objPres = driver.FindElement(By.XPath(tblId)).Enabled;
                    }
                    else
                    {
                        //check to see that the table exists
                        objPres = driver.FindElement(By.XPath(tblId)).Enabled;
                    }

                    if (inArray[1] != "CU")
                    {
                        //add string to the test results list
                        tmpString = "Searching for the " + tblName + " table........(" + stpNum + ")";
                        tstresult = arrayAppend(objPres.ToString(), tmpString, "80", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);
                    }

                    for (int tblCount = 0; tblCount < itmCount; tblCount++)
                    {
                        numRows = driver.FindElements(By.XPath(tblId + "/tbody/tr")).Count;

                        //x is the row number currently being processed
                        for (int x = 0; x < numRows; x++)
                        {
                            try
                            {
                                //check all other tables exceprt the Events table which is slightly different
                                if (tblName != "Events")
                                {
                                    //check if the table item is present and get the text of the searched item
                                    if (x == 0)
                                    {
                                        if ((tblMove == 0 && schCol == "0") || (tblMove == 0 && schCol == "1"))
                                        {
                                            //check if initial xpath object is present
                                            objPres = driver.FindElement(By.XPath(tblId + "/tbody/tr/td")).Enabled;

                                            //get the row text of the [0] item
                                            txtPath = tblId + "/tbody/tr/td";
                                            rowText = driver.FindElement(By.XPath(tblId + "/tbody/tr/td")).Text;
                                        }
                                        else
                                        {
                                            //check if initial xpath object is present
                                            objPres = driver.FindElement(By.XPath(tblId + "/tbody/tr/td[" + schCol + "]")).Enabled;

                                            txtPath = tblId + "/tbody/tr/td[" + schCol + "]";
                                            //get the row text of the [x] item
                                            rowText = driver.FindElement(By.XPath(tblId + "/tbody/tr/td[" + schCol + "]")).Text;
                                        }
                                    }
                                    else
                                    {
                                        if (schCol == "1")
                                        {
                                            txtPath = tblId + "/tbody/tr[" + (x + 1).ToString() + "]/td";
                                            rowText = driver.FindElement(By.XPath(tblId + "/tbody/tr[" + (x + 1).ToString() +
                                                "]/td")).Text;
                                        }
                                        else
                                        {
                                            txtPath = tblId + "/tbody/tr[" + (x + 1).ToString() + "]/td[" + schCol + "]";
                                            rowText = driver.FindElement(By.XPath(tblId + "/tbody/tr[" + (x + 1).ToString() +
                                                "]/td[" + schCol + "]")).Text;
                                        }
                                    }
                                }
                                //the Events table has a different make up in that its entries are tables with a table. So the path needs to be constructed a little differently
                                else
                                {
                                    if (x == 0)
                                    {
                                        //check if initial xpath object is present
                                        objPres = driver.FindElement(By.XPath(tblId + "/tbody/tr/td/table/tbody/tr/td[" + schCol + "]")).Enabled;

                                        //get the row text of the [0] item
                                        txtPath = tblId + "/tbody/tr/td/table/tbody/tr/td[" + schCol + "]";
                                        rowText = driver.FindElement(By.XPath(tblId + "/tbody/tr/td/table/tbody/tr/td[" + schCol + "]" + suffix)).Text;
                                    }
                                    else
                                    {
                                        txtPath = tblId + "/tbody/tr[" + (x + 1).ToString() + "]/td/table/tbody/tr/td[" + schCol + "]";
                                        rowText = driver.FindElement(By.XPath(tblId + "/tbody/tr[" + (x + 1).ToString() + "/td/table/tbody/tr/td[" + schCol + "]")).Text;
                                    }
                                }
                            }
                            catch
                            {
                                continue;
                            }

                            //if (inArray[12] != "Y")
                                //see if the search string is in the table entry
                                rowText = TestSuite.getTableEntry(driver, txtPath, rowText.Trim(), schText.Trim(), vfyString, schText.Trim().Length);
                            //else
                                //rowText = TestSuite.

                            //get the row text from the beginning to the strLen and check if it matches the schText
                            //this is in case any suffix entries (ex: member count) are present
                            if (rowText == schText.Trim())
                            {
                                if (tblName != "Events")
                                {
                                    //checking to see if the cleanup operation involves a group. Need to check if the group hasn't been approved
                                    //it won't show as a link. In this case, the schCol variable needs to be moved over 4 columns as the group can't
                                    //be deleted
                                    if (inArray[1] == "CU" && tblName == "Groups")
                                    {
                                        //get the fndPath stipulated. At this point we are looking for a link
                                        //if (x == 0)
                                            //fndPath = tblId + "/tbody/tr/td[" + schCol + "]" + suffix;
                                        //else
                                        fndPath = tblId + "/tbody/tr[" + (x + 1).ToString() + "]/td[" + schCol + "]" + suffix;

                                        //check if a link exists. The text already matches. This is for a group. If the group has not been approved yet, it can't be
                                        //opened and deleted. It will need to be deleted from table grid. This will look for a link vis-a-vis a text entry
                                        gpPres = tstObj.IsElementPresent(By.XPath(fndPath));

                                        //if the link does not exist, the group cannot be accessed so the schCol variable needs to moved over 4 columns to the delete icon
                                        if (gpPres == false)
                                        {
                                            schCol = "5";
                                            suffix = "/div/a/img";

                                            //get the fndPath stipulated. At this point we are looking for a link
                                            if (x == 0)
                                                fndPath = tblId + "/tbody/tr/td[" + schCol + "]" + suffix;
                                            else
                                                fndPath = tblId + "/tbody/tr[" + (x + 1).ToString() + "]/td[" + schCol + "]" + suffix;
                                        }
                                    }
                                    else
                                    {

                                        if (x == 0 && ((Convert.ToInt32(schCol) + (tblMove)) == 0 || (Convert.ToInt32(schCol) + (tblMove)) == 1))
                                            fndPath = tblId + "/tbody/tr/td" + suffix;
                                        else if (x == 0)
                                            fndPath = tblId + "/tbody/tr/td[" + (Convert.ToInt32(schCol) + (tblMove)) + "]" + suffix;
                                        else if ((Convert.ToInt32(schCol) + (tblMove)) == 0 || (Convert.ToInt32(schCol) + (tblMove)) == 1)
                                            fndPath = tblId + "/tbody/tr[" + (x + 1) + "]/td" + suffix;
                                        else
                                            fndPath = tblId + "/tbody/tr[" + (x + 1) + "]/td[" + (Convert.ToInt32(schCol) + (tblMove)) + "]" + suffix;
                                    }
                                }
                                else
                                {

                                }

                                //if the item is to be selected, enter this portion of the if statement
                                if (slct == "Y")
                                {
                                    //set clkCell to a WebElement at the fndPath xpath
                                    driver.FindElement(By.XPath(fndPath)).Click();

                                    if (inArray[1] != "CU")
                                    {
                                        //Record the result
                                        tmpString = "The item '" + schText + "' was found in the the " + tblName + " table";
                                        tstresult = arrayAppend(objPres.ToString(), tmpString, "1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);
                                    }
                                }

                                //added code
                                else if (slct == "N")
                                {
                                    Boolean view;
                                    found = true;
                                    view = driver.FindElement(By.XPath(fndPath)).Displayed;
                                    if (view && vis == "Y")
                                    {
                                        if (inArray[1] != "CU")
                                        {
                                            //Record the result
                                            tmpString = "The item at position(" + fndPath + ") was found in the the " + tblName + " table, and is visible";
                                            tstresult = arrayAppend(objPres.ToString(), tmpString, "1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);
                                        }
                                    }
                                    else if (view && vis == "N")
                                    {
                                        if (inArray[1] != "CU")
                                        {
                                            //Record the result
                                            tmpString = "The item at position(" + fndPath + ") was found in the the " + tblName + " table, and should not be visible";
                                            tstresult = arrayAppend(objPres.ToString(), tmpString, "-1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);
                                        }
                                    }
                                }

                                //set fndItem to 1 to denaote that the itme has been found
                                fndItem = 1;
                                break;
                            }
                            //increment the fndPath string to to the next row before incrementing x in the for loop if the
                            //current row doesn't match
                            else
                            {

                                fndPath = tblId + "/tbody/tr[" + (x + 1).ToString() + "]";
                            }
                        }

                        //if the item is not found and there are mutiple pages, select the next page
                        if (fndItem != 1)
                        {
                            if (tblCount != itmCount)
                            {
                                //select the next page ion nthe table page list
                                driver.FindElement(By.LinkText((tblCount + 2).ToString())).Click();
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }

                    //if the item was not found in the table, record the result in the result file
                    if (fndItem != 1)
                    {
                        //in inArray[1] is 'CU' and there is nothing found this is an expected (possible) condition and so
                        //there is no need to log a result. Script should continue with no errors
                        if (inArray[1] != "CU")
                        {
                            if (slct == "X")
                            {
                                objPres = false;
                                //Record the result
                                tmpString = "The item '" + schText + "' was not found in the the " + tblName + " table";
                                tstresult = arrayAppend(objPres.ToString(), tmpString, "1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);
                            }
                            else
                            {
                                //Set objPres to false to indicate that no itwm was found
                                objPres = false;

                                //Record the result
                                tmpString = "The item '" + schText + "' was not found in the the " + tblName + " table";
                                tstresult = arrayAppend(objPres.ToString(), tmpString, "-1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);

                                //set the fndExcep escape variable to leave the app
                                fndExcep = -1;
                            }
                        }
                    }

                    //if a modal table, return focus to the default window
                    if (chkMod == "Y")
                    {
                        driver.SwitchTo().DefaultContent();
                        Thread.Sleep(750);
                    }
                }
                catch (Exception e)
                {
                    if (slct == "N" && found == true)
                    {
                        if (vis == "N")
                        {
                            //Record the result
                            tmpString = "The item at position(" + fndPath + ") was found in the the " + tblName + " table, and is not visible";
                            tstresult = arrayAppend(objPres.ToString(), tmpString, "1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);
                        }
                        else if (vis == "Y")
                        {
                            //Record the result
                            tmpString = "The item at position(" + fndPath + ") was found in the the " + tblName + " table, and is not visible";
                            tstresult = arrayAppend(objPres.ToString(), tmpString, "-1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);
                        }
                    }
                    else
                    {
                        if (slct == "X")
                        {
                            //Record the result
                            tmpString = "The item '" + schText + "' was not found in the the " + tblName + " table";
                            tstresult = arrayAppend(objPres.ToString(), tmpString, "1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);
                        }
                        else
                        {
                            //Record the result
                            tmpString = e.Message;
                            tstresult = arrayAppend(objPres.ToString(), tmpString, "-1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);

                            //set the fndExcep escape variable to leave the app
                            fndExcep = -1;
                        }
                    }
                }
        }
        public void calendarControl(tstObject tstObj, string[] inArray, string stpNum, string pth, ref string[,] tstresult, out int fndExcep)
        {
            bool objPres;               //boolean that determines if the calendar control is present
                string thsDate;             //the date the control is looking at. Compared against the date to select
                string clkPath;             //the path of the matching item to be clicked
                string activeTab;           //the active tab on the app. used to determine how to handle each control
                string clkCntrl;            //xpath to the calendar icon on the page
                string calXpath;            //xpath to the calendar control
                string nmCalendar;          //the name of the calendar control to output to the results file
                string isPopup;             //flag var that determines if the calendar is a popup of
                string inPath;
                string direction;           //the direction to move from today's date for a sliding date
                string numDays;             //the number of days to move forward or backwards for a sliding date
                string totDirection;        //combined direction and numDays for a sliding date
                string mthXpath;            //month xpath suffix - leads to the calendar control header
                string dateXpath;           //date xpath suffix - leads to the calendar control date table
                string dispMth;             //the initial month displayed on the calendar control when it opens (current month)
                int intMth;                 //int value of a month string (e.g. January = 1; February = 2, etc.)
                int diffMth;                //the difference between the initial month displayed and the month to find
                int dispYr;                 //the initial year displayed on the calendar control when it opens(current year)
                int yr;                     //year var extracted from date sent in
                int mth;                    //month var extracted from date sent in
                int day;                    //date var extracted from date sent in
                int numRows;                //the number of table rows containing dates in a month
                int fndItem;                //flag variable noting that the item has been found in the calendar control
                DateTime inDate;            //converted date from inArray into a DateTime variable
                DateTime newDate;           //sliding date from input
                DateTime tgtMonth;          //the target month to navigate to onbce the calendar control opens

                //initialize variables and set locals from inArray
                fndExcep = 0;
                fndItem = 0;
                objPres = true;
                calXpath = inArray[0];
                mthXpath = inArray[1];
                dateXpath = inArray[2];
                clkCntrl = inArray[3];
                isPopup = inArray[4];
                nmCalendar = inArray[5];

                try
                {
                    //get the first two letter of inArray. A value of 'TO' or 'YE' means a sliding value
                    //of TODAY, TOMORROW, OR YESTERDAY. The app will need to convert this to a DateTime var
                if (inArray[6].Substring(0, 2) == "TO" || inArray[6].Substring(0, 2) == "YE")
                    {
                        //extract the right day and time from sliding date input. The default is (TODAY + xx)
                        switch (inArray[6])
                        {
                            case "TODAY":
                            {
                                yr = DateTime.Now.Year;
                                mth = DateTime.Now.Month;
                                day = DateTime.Now.Day;
                                break;
                            }
                            case "TOMORROW":
                            {
                                //format a sliding date to today's date to start from
                                newDate = DateTime.ParseExact(inArray[6], "MM/dd/yyyy", null);

                                //add one day to to get the new date.
                                inDate = newDate.AddDays(1);

                                //get the string variable to perform calendar control operations
                                yr = inDate.Year;
                                mth = inDate.Month;
                                day = inDate.Day;

                                break;
                            }
                            case "YESTERDAY":
                            {
                                //format a sliding date to today's date to start from
                                newDate = DateTime.ParseExact(inArray[6], "MM/dd/yyyy", null);

                                //add one day to to get the new date.
                                inDate = newDate.AddDays(-1);

                                //get the string variable to perform calendar control operations
                                yr = inDate.Year;
                                mth = inDate.Month;
                                day = inDate.Day;

                                break;
                            }
                            default:
                            {
                                //set variables
                                numDays = "";
                                direction = "";

                                //format a sliding date to today's date to start from
                                newDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

                                //get the number of days to go forward or backwards
                                getTimespan(inArray[6], ref numDays, ref direction);

                                //combine numDays and direction
                                totDirection = direction + numDays;

                                //add the number of day(s) specified to to get the new date.
                                inDate = newDate.AddDays(Convert.ToInt32(totDirection));

                                //get the string variable to perform calendar control operations
                                yr = inDate.Year;
                                mth = inDate.Month;
                                day = inDate.Day;

                                break;
                            }

                        }
                    }
                    else
                    {
                        //convert the date sent in from the data source into a C# DateTime variable to split into its components
                        inDate = DateTime.ParseExact(inArray[6], "MM/dd/yyyy", null);

                        //split the indate DateTime variable into it components
                        yr = inDate.Year;
                        mth = inDate.Month;
                        day = inDate.Day;
                    }

                    tgtMonth = new DateTime(yr, mth, day);

                    inPath = "/html/body/table/tbody/tr/td/table/tbody/tr[2]/td/div/div[2]/table/tbody/tr[2]/td/ul/li";

                    //add string to the test results list
                    tmpString = "Searching for the " + nmCalendar + " calendar control........(" + stpNum + ")";
                    tstresult = arrayAppend(objPres.ToString(), tmpString, "80", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);

                    //verify that the desired calendar control is present. If not throw an excerption
                    if (isPopup == "Y")
                    {
                        //verify that calendar control icon is where it should be
                        objPres = tstObj.IsElementPresent(By.XPath(clkCntrl));

                        //click the calendar control to launch them popup if present. throw an exception if not
                        if(objPres == true)
                        {
                            driver.FindElement(By.XPath(clkCntrl)).Click();
                        }
                        else
                        {
                            throw new ElementNotVisibleException();
                        }
                    }
                    else
                    {
                        objPres = tstObj.IsElementPresent(By.XPath(calXpath));
                    }

                    //get the active tag in app
                    activeTab = getActiveTab(inPath);

                    if (activeTab != "Events")
                    {
                        //get the displayed month in the calendar popup
                        dispMth = (driver.FindElement(By.XPath(calXpath + mthXpath)).Text);

                        //convert to the equivalent int value (January = 1, etc.)
                        intMth = getMonth(dispMth);

                        //get the displayed year
                        dispYr = Convert.ToInt32(driver.FindElement(By.XPath(calXpath + mthXpath + "[2]")).Text);

                        //make a new datetime variable to use to get the month difference
                        inDate = new DateTime(dispYr, intMth, 1);

                        //get the month difference
                        diffMth = getMonthDiff(tgtMonth, inDate);

                        //click the back or forward buttons diffMth times to get the calendar control onto the correct month
                        for (int x = 0; x < Math.Abs(diffMth); x++)
                        {
                            if (diffMth < 0)
                            {
                                driver.FindElement(By.XPath(calXpath + "/div/a")).Click();
                            }
                            else
                            {
                                driver.FindElement(By.XPath(calXpath + "/div/a[2]")).Click();
                            }
                        }

                        //get the number of rows in the calendar that contain dates
                        numRows = driver.FindElements(By.XPath(calXpath + dateXpath + "/tbody/tr")).Count;

                        //scroll down each row after scrolling across
                        for (int x = 0; x < numRows; x++)
                        {
                            for (int y = 0; y < 7; y++)
                            {
                                //set the path to extract the cell text from
                                if (x == 0 && y == 0)
                                {
                                    clkPath = calXpath + dateXpath + "/tbody/tr/td";
                                }
                                else if (x == 0 && y > 0)
                                {
                                    clkPath = calXpath + dateXpath + "/tbody/tr/td[" + (y + 1).ToString() + "]";
                                }
                                else if (x > 0 && y == 0)
                                {
                                    clkPath = calXpath + dateXpath + "/tbody/tr[" + (x + 1).ToString() + "]/td";
                                }
                                else
                                {
                                    clkPath = calXpath + dateXpath + "/tbody/tr[" + (x + 1).ToString() + "]/td[" + (y + 1).ToString() + "]";
                                }

                                //get the text of the calendar block
                                thsDate = driver.FindElement(By.XPath(clkPath)).Text;

                                //compare to the date expected. if it matcheas set up to exit both for loops
                                if (thsDate == day.ToString())
                                {
                                    //Click the element
                                    driver.FindElement(By.XPath(clkPath)).Click();

                                    //set fndElement to begin the escape sequence
                                    fndItem = 1;

                                    //log the result
                                    tmpString = "The date " + inArray[6] + " was successfully selected in the " + nmCalendar + " calendar control";
                                    tstresult = arrayAppend(objPres.ToString(), tmpString, "1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);

                                    break;
                                }
                            }

                            if (fndItem == 1)
                                break;
                        }
                    }
                    else
                    {
                    }
                }
                catch (ElementNotVisibleException e)
                {
                    //add string to the test results list
                    tmpString = "The " + nmCalendar + " calendar control was not found next to the " + nmCalendar + " field";
                    tstresult = arrayAppend(objPres.ToString(), tmpString, "-1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);

                    fndExcep = -1;

                    //add string to the test results list
                    tmpString = e.Message;
                    tstresult = arrayAppend(objPres.ToString(), tmpString, "-1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);
                }
                catch(Exception e)
                {
                    //add string to the test results list
                    tmpString = "ERROR FOUND:...........(" + stpNum + ")";
                    tstresult = arrayAppend(objPres.ToString(), tmpString, "-1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);

                    fndExcep = -1;

                    //add string to the test results list
                    tmpString = e.Message;
                    tstresult = arrayAppend(objPres.ToString(), tmpString, "-1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);
                }
        }
        public void Login(tstObject tstObj, string[] inArray, string baseURL, string stpNum, int browser, string product, string pth, out int fndExcep, ref string[,] tstresult)
        {
            bool objPres;
                int isPres;
                string btnLogin;
                string lnkLogout;
                string typLogin;
                string username;
                string password;
                IJavaScriptExecutor js = driver as IJavaScriptExecutor;
                WebDriverWait wait;

                wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

                //initialize variables
                fndExcep = 0;
                typLogin = "";
                username = "";
                password = "";
                objPres = false;

                //Navigate to the baseURL
                driver.Navigate().GoToUrl(baseURL + "/");

                switch(product)
                {
                    case "Echo":
                    {
                        try
                        {
                            if (browser == 2 || browser == 0)
                            {
                                lnkLogout = "/html/body/table/tbody/tr/td/table/tbody/tr/td/div/div[3]/table/tbody/tr/td[5]/div/a";
                                objPres = tstObj.IsElementPresent(By.XPath(lnkLogout));

                                if (objPres == true)
                                {
                                    driver.FindElement(By.XPath(lnkLogout)).Click();
                                    wait.Until(drv => driver.FindElement(By.Id("edit-name")).Displayed);
                                }
                            }

                            //assign variables from the incoming inArray from the database
                            for (int x = 0; x < inArray.Length; x++)
                            {
                                if (inArray[x] != "")
                                {
                                    switch (x)
                                    {
                                        case 0:
                                            username = inArray[x];

                                            if (username == "*****@*****.**")
                                                objPres = true;
                                            break;
                                        case 1:
                                            password = inArray[x];
                                            break;
                                    }
                                }
                            }

                            objPres = tstObj.IsElementPresent(By.XPath("id('edit-name')"));

                            Thread.Sleep(250);

                            //Clear the Username field
                            driver.FindElement(By.XPath("/html/body/div[3]/table/tbody/tr[2]/td[2]/table/tbody/tr/td[2]/div[2]/div/form/div" +
                                "/div/div[2]/div/div/div/div/div/div/div/div/table/tbody/tr/td/input")).Clear();

                            //Populate the Username field with the username parameter sent from the data sheet
                            driver.FindElement(By.XPath("/html/body/div[3]/table/tbody/tr[2]/td[2]/table/tbody/tr/td[2]/div[2]/div/form/div" +
                                "/div/div[2]/div/div/div/div/div/div/div/div/table/tbody/tr/td/input")).SendKeys(username);

                            Thread.Sleep(250);

                            isPres = driver.FindElements(By.XPath("id('text')")).Count;

                            if (isPres > 0)
                            {
                                //click the password field. This will change the input type
                                driver.FindElement(By.XPath("id('text')")).Click();

                                js.ExecuteScript("swapInput()");
                            }

                            //Clear the password field
                            driver.FindElement(By.XPath("/html/body/div[3]/table/tbody/tr[2]/td[2]/table/tbody/tr/td[2]/div[2]/div/form/div" +
                                "/div/div[2]/div/div/div/div/div/div/div/div/table/tbody/tr[3]/td/input")).Clear();

                            //Populate the Password field with the password parameter sent from the data sheet
                            driver.FindElement(By.XPath("/html/body/div[3]/table/tbody/tr[2]/td[2]/table/tbody/tr/td[2]/div[2]/div/form/div" +
                                "/div/div[2]/div/div/div/div/div/div/div/div/table/tbody/tr[3]/td/input")).SendKeys(password);

                            //Click the Sign On button
                            // driver.FindElement(By.XPath("id('edit-pass')")).SendKeys("{TAB}");
                            objPres = tstObj.IsElementPresent(By.Id("edit-submit"));
                            driver.FindElement(By.Id("edit-submit")).Click();

                            if (browser != 0)
                            {
                                //Verify login was successful
                                objPres = driver.FindElement(By.LinkText("Home")).Enabled;
                            }

                            //log result to the result file
                            tmpString = "Logging into Echo as " + username + ": (" + stpNum + ")";
                            tstresult = arrayAppend(objPres.ToString(), tmpString, "80", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);
                        }
                        catch (Exception e)
                        {
                            //Record failed result
                            tmpString = e.Message;
                            tstresult = arrayAppend("False", tmpString, "-1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);

                            //Record exception and begin exit process
                            fndExcep = -1;

                        }

                        break;
                    }
                    case "Strive - SSD":
                    {
                        try
                        {
                            //assign variables from the incoming inArray from the database
                            for (int x = 0; x < inArray.Length; x++)
                            {
                                if (inArray[x] != "")
                                {
                                    switch (x)
                                    {
                                        case 0:
                                            username = inArray[x];
                                            break;
                                        case 1:
                                            password = inArray[x];
                                            break;
                                        case 2:
                                            typLogin = inArray[x];
                                            break;
                                    }
                                }
                            }

                            //click the appropriate login button
                            switch (typLogin)
                            {
                                case "live":
                                    //click the login type button
                                    driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/aside/div/div/div/ul/li/button")).Click();

                                    //clear the username field
                                    driver.FindElement(By.XPath("/html/body/div[2]/div/div/div/div[2]/div[5]/div/form/div/div[4]/div/input")).Clear();

                                    //enter the username
                                    driver.FindElement(By.XPath("/html/body/div[2]/div/div/div/div[2]/div[5]/div/form/div/div[4]/div/input")).SendKeys(username);

                                    //clear the password field
                                    driver.FindElement(By.XPath("/html/body/div[2]/div/div/div/div[2]/div[5]/div/form/div/div[6]/div/input")).Clear();

                                    //enter the password
                                    driver.FindElement(By.XPath("/html/body/div[2]/div/div/div/div[2]/div[5]/div/form/div/div[6]/div/input")).SendKeys(password);

                                    //click the Sign In button
                                    driver.FindElement(By.XPath("/html/body/div[2]/div/div/div/div[2]/div[5]/div/form/div[2]/input")).Click();
                                    break;
                                case "gmail":
                                    driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/aside/div/div/div/ul/li[2]/button"));
                                    break;
                                case "yahoo":
                                    driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/aside/div/div/div/ul/li[3]/button"));
                                    break;

                            }

                            //log result to the result file
                            tmpString = "Logging into Echo as " + username + ": (" + stpNum + ")";
                            tstresult = arrayAppend(objPres.ToString(), tmpString, "80", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);
                        }
                        catch(Exception e)
                        {
                            //Record failed result
                            tmpString = e.Message;
                            tstresult = arrayAppend("False", tmpString, "-1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult);

                            //Record exception and begin exit process
                            fndExcep = -1;
                        }
                        break;
                    }
                }
        }