//Click the link sent from the spreadsheet public void navLinks(tstObject tstObj, bool objPres, string[] inArray, string stpNum, string pth, ref string[,] tstresult, out int fndExcep) { int strLen; string iconNum; string inString; string lnkText; string lnkID; IJavaScriptExecutor js = driver as IJavaScriptExecutor; //initilize variables lnkID = ""; fndExcep = 0; inString = ""; lnkText = ""; if (inArray[0] != "SWITCH TAB") { objPres = driver.FindElement(By.XPath(inArray[0])).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: inString = inArray[x]; break; case 1: lnkText = inArray[x]; break; } } } if (inString != "SWITCH TAB") { //Format the link name //add string to the test results list tmpString = "Clicking the " + lnkText + " link..... (" + stpNum + ")"; tstresult = arrayAppend(objPres.ToString(), tmpString, "80", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult); try { //get the string length of the xpath being submitted for click strLen = inString.Length; //the app looks for a 63 char string to denote a click in the top nav. If an xpath is shorter than 63 characters, there //is no need to check and the app can just proceed to click the link being sent in if (strLen >= 63) { //determine if the link to be clicked is in the top nav bar (gear, google, or flag icons) if (inString.Substring(0, 63) == "/html/body/table/tbody/tr/td/table/tbody/tr/td/div/div[3]/table") { iconNum = inString.Substring(76, 1); switch (iconNum) { case "2": { lnkID = "notification-data"; break; } case "3": { lnkID = "gapps-data"; break; } case "4": { lnkID = "settings-data"; break; } default: { lnkID = ""; break; } } } } //switch statement governing how the app clicks on a link switch (lnkID) { case "settings-data": { //click on the gear icon driver.FindElement(By.XPath("id('settings-tipsy')")).Click(); //Execute onclick javascript event js.ExecuteScript("settings_tipsy_call()"); //make the resulting options list visible js.ExecuteScript("$('#settings-data').show();"); //click on the link passed in to the navLinks Thread.Sleep(400); driver.FindElement(By.XPath(inString)).Click(); //return the app to the previous state js.ExecuteScript("$('#settings-data').hide();"); break; } case "gapps-data": { //click on the google icon js.ExecuteScript("gapps_tipsy_call()"); //make the resulting google options list visible js.ExecuteScript("$('#gapps-data').show();"); //click on the link passed in to the navLinks Thread.Sleep(400); driver.FindElement(By.XPath(inString)).Click(); //return the app to the previous state js.ExecuteScript("$('#gapps-data').hide();"); break; } case "notification-data": { ////click on the flag icon js.ExecuteScript("notification_tipsy_call()"); //make the resulting google options list visible js.ExecuteScript("$('#notification-data').show();"); //click on the link passed in to the navLinks Thread.Sleep(400); driver.FindElement(By.XPath(inString)).Click(); //return the app to the previous state js.ExecuteScript("$('#notification-data').hide();"); break; } default: Thread.Sleep(400); driver.FindElement(By.XPath(inString)).Click(); break; } tmpString = "Successfully clicked the " + lnkText + " link"; 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 = e.Message; tstresult = arrayAppend(objPres.ToString(), tmpString, "-1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult); fndExcep = -1; } } else { try { //Format the link name //add string to the test results list tmpString = "Navigating to tab " + lnkText + "..... (" + stpNum + ")"; tstresult = arrayAppend(objPres.ToString(), tmpString, "80", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult); tstObj.switchTab(tstObj, inArray, stpNum, pth, out fndExcep, stpNum); driver.FindElement(By.XPath(inString)).Submit(); //driver.FindElement(By. tmpString = "Successfully clicked the " + lnkText + " link"; 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 = e.Message; tstresult = arrayAppend(objPres.ToString(), tmpString, "-1", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, tstresult); fndExcep = -1; } } }