private void PowerUserLoginCheck(string sProjectName, string sWebAccessIP, string sTestLogFolder, string sBrowser) { EventLog.AddLog("Power user check"); baseUrl = "http://" + sWebAccessIP; if (sBrowser == "Internet Explorer") { EventLog.AddLog("Browser= Internet Explorer"); api = new AdvSeleniumAPI("IE", ""); System.Threading.Thread.Sleep(1000); } else if (sBrowser == "Mozilla FireFox") { EventLog.AddLog("Browser= Mozilla FireFox"); api = new AdvSeleniumAPI("FireFox", ""); System.Threading.Thread.Sleep(1000); } // Launch Firefox and login api.LinkWebUI(baseUrl + "/broadWeb/bwconfig.asp?username=admin"); api.ById("userField").Enter("").Submit().Exe(); PrintStep("Login WebAccess"); // Configure project by project name api.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp?pos=project') and contains(@href, 'ProjName=" + sProjectName + "')]").Click(); PrintStep("Configure project"); // Start view api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//tr[2]/td/a/font").Click(); PrintStep("Start View"); // Control browser int iIE_Handl, iIE_Handl_2, iIE_Handl_3, iIE_Handl_4, iIE_Handl_5, iIE_Handl_6, iIE_Handl_7, iWA_MainPage = 0; switch (slanguage) { case "ENG": iIE_Handl = tpc.F_FindWindow("IEFrame", "Node : TestSCADA - main:untitled"); iIE_Handl_2 = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", ""); iIE_Handl_3 = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "Node : TestSCADA - Internet Explorer"); iIE_Handl_4 = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", ""); iIE_Handl_5 = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", ""); iIE_Handl_6 = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", ""); iIE_Handl_7 = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", ""); iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled"); break; case "CHT": iIE_Handl = tpc.F_FindWindow("IEFrame", "節點 : TestSCADA - main:untitled"); iIE_Handl_2 = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", ""); iIE_Handl_3 = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "節點 : TestSCADA - Internet Explorer"); iIE_Handl_4 = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", ""); iIE_Handl_5 = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", ""); iIE_Handl_6 = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", ""); iIE_Handl_7 = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", ""); iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled"); break; case "CHS": iIE_Handl = tpc.F_FindWindow("IEFrame", "节点 : TestSCADA - main:untitled"); iIE_Handl_2 = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", ""); iIE_Handl_3 = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "节点 : TestSCADA - Internet Explorer"); iIE_Handl_4 = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", ""); iIE_Handl_5 = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", ""); iIE_Handl_6 = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", ""); iIE_Handl_7 = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", ""); iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled"); break; case "JPN": iIE_Handl = tpc.F_FindWindow("IEFrame", "ノード : TestSCADA - main:untitled"); iIE_Handl_2 = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", ""); iIE_Handl_3 = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "ノード : TestSCADA - Internet Explorer"); iIE_Handl_4 = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", ""); iIE_Handl_5 = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", ""); iIE_Handl_6 = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", ""); iIE_Handl_7 = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", ""); iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled"); break; case "KRN": iIE_Handl = tpc.F_FindWindow("IEFrame", "노드 : TestSCADA - main:untitled"); iIE_Handl_2 = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", ""); iIE_Handl_3 = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "노드 : TestSCADA - Internet Explorer"); iIE_Handl_4 = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", ""); iIE_Handl_5 = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", ""); iIE_Handl_6 = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", ""); iIE_Handl_7 = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", ""); iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled"); break; case "FRN": iIE_Handl = tpc.F_FindWindow("IEFrame", "Noeud : TestSCADA - main:untitled"); iIE_Handl_2 = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", ""); iIE_Handl_3 = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "Noeud : TestSCADA - Internet Explorer"); iIE_Handl_4 = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", ""); iIE_Handl_5 = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", ""); iIE_Handl_6 = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", ""); iIE_Handl_7 = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", ""); iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled"); break; default: iIE_Handl = tpc.F_FindWindow("IEFrame", "Node : TestSCADA - main:untitled"); iIE_Handl_2 = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", ""); iIE_Handl_3 = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "Node : TestSCADA - Internet Explorer"); iIE_Handl_4 = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", ""); iIE_Handl_5 = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", ""); iIE_Handl_6 = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", ""); iIE_Handl_7 = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", ""); iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled"); break; } /* * int iIE_Handl = tpc.F_FindWindow("IEFrame", "Node : TestSCADA - main:untitled"); * int iIE_Handl_2 = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", ""); * int iIE_Handl_3 = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "Node : TestSCADA - Internet Explorer"); * int iIE_Handl_4 = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", ""); * int iIE_Handl_5 = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", ""); * int iIE_Handl_6 = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", ""); * int iIE_Handl_7 = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", ""); * int iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled"); */ if (iWA_MainPage > 0) { //SendMessage(iWA_MainPage, BM_CLICK, 0, 0); //SendMessage(iWA_MainPage, WM_RBUTTONDOWN, 0, 0); //SendMessage(iWA_MainPage, WM_RBUTTONDOWN, MK_RBUTTON, 0); tpc.F_PostMessage(iWA_MainPage, tpc.V_WM_KEYDOWN, tpc.V_VK_ESCAPE, 0); System.Threading.Thread.Sleep(1000); } else { EventLog.AddLog("Cannot get Start View WebAccess Main Page handle"); } // Login keyboard int iLoginKeyboard_Handle; switch (slanguage) { case "ENG": iLoginKeyboard_Handle = tpc.F_FindWindow("#32770", "Login"); break; case "CHT": iLoginKeyboard_Handle = tpc.F_FindWindow("#32770", "登入"); break; case "CHS": iLoginKeyboard_Handle = tpc.F_FindWindow("#32770", "登录"); break; case "JPN": iLoginKeyboard_Handle = tpc.F_FindWindow("#32770", "ログイン"); break; case "KRN": iLoginKeyboard_Handle = tpc.F_FindWindow("#32770", "로그인"); break; case "FRN": iLoginKeyboard_Handle = tpc.F_FindWindow("#32770", "Connexion"); break; default: iLoginKeyboard_Handle = tpc.F_FindWindow("#32770", "Login"); break; } int iEnterText = tpc.F_FindWindowEx(iLoginKeyboard_Handle, 0, "Edit", ""); int iEnter_PW = tpc.F_GetWindow(iEnterText, tpc.V_GW_HWNDNEXT); if (iEnterText > 0 && iEnter_PW > 0) { SendCharToHandle(iEnterText, 100, "PowerUser"); SendCharToHandle(iEnter_PW, 100, "12345678"); tpc.F_PostMessage(iEnterText, tpc.V_WM_KEYDOWN, tpc.V_VK_RETURN, 0); System.Threading.Thread.Sleep(1000); } else { EventLog.AddLog("Cannot get Login keyboard handle"); } Thread.Sleep(2000); EventLog.PrintScreen("PowerUserCheck"); api.Quit(); PrintStep("Quit browser"); }