def OperateACWebPage(self,bCA,lst):
        #global Obj_WaitDialog_Cancel
        #g_Group_Idx
        #define 'ie' object to control web page
        ie = PAMIE()

        #check version of IE. different version have different operate.
        nVer = self.getIEVersion(ie)                        
        if nVer == -1:
            log_public(WEB_ERR_NO_0002+dstURL[KEY_URL])
            self.m_ERROR_MSG = WEB_ERR_NO_0002+dstURL[KEY_URL]
            return False                      
        #KillCA = True
        KillCA = bCA
        #loop to control every web page,all the control information storage at lst.
        #we loop to get page information at 'lst' to control web pages.
        #We call it one page_operate.
        lstLen = len(lst)
        for i in range(lstLen):
            
            #define 'lstSub',this list go to storage web page information.
            lstSub=[]
            lstSub.extend(lst[i])


            #loop to control every control_components of one web page.
            #we loop to get control_components at 'lstSub' to control control_components of one web pages. 
            #We call it line_operation. 
            #Obj_WaitDialog_Cancel = 0  #if dialog popup after you click a button.you need to use WAIT DIALOG EVENT. This variable will starage the object.        
            lstSubLen = len(lstSub)
            for j in range(0,lstSubLen):
                
                #get URL path
                #URL path is storage at '1' index of 'lstSubLen',so judge 'j' wether equal 1.
                if j == 0 :
                    
                    #define 'dstURL' as dictionary to storage URL and its value.
                    dstURL={}
                    dstURL.update(lstSub[j])                
                    
                    #URL Value can be None sometime,we will not go to the page when the value is 'NONE'.
                    #if the value of 'KEY_URL' not NONE,we will got the page by 'navigate' function.
                    if dstURL[KEY_URL]!=KEY_URL_NONE:
                        ret = ie.navigate(dstURL[KEY_URL])
                        if ret == False:
                            ie.quit()
                            #write logging
                            log_public(WEB_ERR_NO_0001+dstURL[KEY_URL])
                            self.m_ERROR_MSG = WEB_ERR_NO_0001+dstURL[KEY_URL]
                            return False
                        
                        if KillCA == 'CAON':
                            #IE 8 need to click 'overridelink'
                            #IE 6 need to click 'CA authentication dialog'
                            if nVer == 8:                                        
                                time.sleep(1)
                                ret = ie.clickLink('overridelink')
                                #encode
                                if ret == False:
                                    ie.quit()
                                    #write logging
                                    log_public(WEB_ERR_NO_0001+dstURL[KEY_URL])
                                    self.m_ERROR_MSG = WEB_ERR_NO_0001+dstURL[KEY_URL]
                                    return False
                                
                                KillCA = False #not need to kill next time open URL                                                                
                            elif nVer == 6:
                                time.sleep(1)
                                KillCA = False   
                            
                else:
                    #get line_operation.
                    dstComb = {}
                    dstComb.update(lstSub[j])
                    
                    #if 'ASSIST' have '//',This line_operation will be ignore.
                    if dstComb[KEY_ASSIST]== KEY_COMMENT:                        
                        continue
                    
                    #dispatch line_operation.include kinds(set text box, set check box,select list box,...)
                    Value = dstComb[KEY_CONTROLTYPE]
                    if Value == KEY_WEB_TYPE_TEXTBOX:                        
                        if ie.setTextBox(dstComb[KEY_CONTROLNAME], dstComb[KEY_CONTROLVALUE]) == False:
                            log_public(WEB_ERR_NO_0003+dstComb[KEY_CONTROLNAME])
                            self.m_ERROR_MSG = WEB_ERR_NO_0003+dstComb[KEY_CONTROLNAME]
                            return False
                        
                    elif Value== KEY_WEB_TYPE_CHECKBOX:
                        if self.MainCheckBox(ie,dstComb[KEY_ASSIST],dstComb[KEY_CONTROLNAME],dstComb[KEY_CONTROLVALUE]) == False:
                            log_public(WEB_ERR_NO_0004+dstComb[KEY_CONTROLNAME])
                            self.m_ERROR_MSG = WEB_ERR_NO_0004+dstComb[KEY_CONTROLNAME]
                            return False

                    elif Value == KEY_WEB_TYPE_LISTBOX:
                        if self.MainListBox(ie,dstComb[KEY_ASSIST],dstComb[KEY_CONTROLNAME],dstComb[KEY_CONTROLVALUE]) == False:
                            log_public(WEB_ERR_NO_0005+dstComb[KEY_CONTROLNAME])
                            self.m_ERROR_MSG = WEB_ERR_NO_0005+dstComb[KEY_CONTROLNAME]
                            return False 

                    elif Value == KEY_WEB_TYPE_BUTTON:
                        if self.MainButton(ie,dstComb[KEY_ASSIST],dstComb[KEY_CONTROLNAME]) == False:
                            log_public(WEB_ERR_NO_0006+dstComb[KEY_CONTROLNAME])    
                            self.m_ERROR_MSG =  WEB_ERR_NO_0006+dstComb[KEY_CONTROLNAME]                      
                            False

                    elif Value == KEY_WEB_TYPE_WAIT:
                        if self.waitEvent(dstComb[KEY_CONTROLNAME],dstComb[KEY_CONTROLVALUE]) == False:
                            log_public(WEB_ERR_NO_0007+dstComb[KEY_CONTROLNAME])
                            self.m_ERROR_MSG =  WEB_ERR_NO_0007+dstComb[KEY_CONTROLNAME]
                            return False

                    elif Value == KEY_WEB_TYPE_JAVASCRIPT:                        
                        if self.MainJavaScript(ie,dstComb[KEY_ASSIST],dstComb[KEY_CONTROLNAME]) == False:
                           log_public(WEB_ERR_NO_0008+dstComb[KEY_CONTROLNAME])   
                           self.m_ERROR_MSG = WEB_ERR_NO_0008+dstComb[KEY_CONTROLNAME]
                           return False

                    elif Value == KEY_WEB_TYPE_GROUP_CHECKBOX:
                        if  self.GetGoupCheckBoxIndex(ie,dstComb[KEY_CONTROLNAME]) == False:
                           log_public(WEB_ERR_NO_0009+dstComb[KEY_CONTROLNAME])  
                           self.m_ERROR_MSG = WEB_ERR_NO_0009+dstComb[KEY_CONTROLNAME]
                           return False   
        #close ie after operation.                
        ie.quit()     
예제 #2
0
for control_item in control_list:
    if control_item[1]='OK':
        winGuiAuto.clickButton(control_item[0])
"""
ret = False

ie = PAMIE()

#Open login page of AC
ret = ie.navigate('https://192.168.4.232')
if ret == False:
    ie.quit()
#ie.navigate('http://www.baidu.com')

#skip auth page
ie.clickLink('overridelink')
time.sleep(1)

#login AC

ie.setTextBox('UserName', 'icac')  #set user name
ie.setTextBox('PassWord', 'icaclogin')  #set user name

ie.clickButton('LoginChinese')
time.sleep(1)

#ret = ie.navigate('https://192.168.21.200/wlan/wlan_cfg_edit.php')

#Click WLAN menu
#print ie.clickMenu( 'a','Selector.php?MenuID=309', 'WLAN', event=None)
#print ie.clickElement( 'WLAN' )
for control_item in control_list:
    if control_item[1]='OK':
        winGuiAuto.clickButton(control_item[0])
"""
ret = False

ie = PAMIE()

#Open login page of AC
ret = ie.navigate('https://192.168.4.232')
if ret == False:
    ie.quit()
#ie.navigate('http://www.baidu.com')

#skip auth page
ie.clickLink('overridelink')
time.sleep(1)

#login AC

ie.setTextBox('UserName', 'icac')#set user name
ie.setTextBox('PassWord', 'icaclogin')#set user name

ie.clickButton('LoginChinese')
time.sleep(1)

#ret = ie.navigate('https://192.168.21.200/wlan/wlan_cfg_edit.php')

#Click WLAN menu
#print ie.clickMenu( 'a','Selector.php?MenuID=309', 'WLAN', event=None)
#print ie.clickElement( 'WLAN' )
예제 #4
0
    def OperateACWebPage(self, bCA, lst):
        #global Obj_WaitDialog_Cancel
        #g_Group_Idx
        #define 'ie' object to control web page
        ie = PAMIE()

        #check version of IE. different version have different operate.
        nVer = self.getIEVersion(ie)
        if nVer == -1:
            log_public(WEB_ERR_NO_0002 + dstURL[KEY_URL])
            self.m_ERROR_MSG = WEB_ERR_NO_0002 + dstURL[KEY_URL]
            return False
        #KillCA = True
        KillCA = bCA
        #loop to control every web page,all the control information storage at lst.
        #we loop to get page information at 'lst' to control web pages.
        #We call it one page_operate.
        lstLen = len(lst)
        for i in range(lstLen):

            #define 'lstSub',this list go to storage web page information.
            lstSub = []
            lstSub.extend(lst[i])

            #loop to control every control_components of one web page.
            #we loop to get control_components at 'lstSub' to control control_components of one web pages.
            #We call it line_operation.
            #Obj_WaitDialog_Cancel = 0  #if dialog popup after you click a button.you need to use WAIT DIALOG EVENT. This variable will starage the object.
            lstSubLen = len(lstSub)
            for j in range(0, lstSubLen):

                #get URL path
                #URL path is storage at '1' index of 'lstSubLen',so judge 'j' wether equal 1.
                if j == 0:

                    #define 'dstURL' as dictionary to storage URL and its value.
                    dstURL = {}
                    dstURL.update(lstSub[j])

                    #URL Value can be None sometime,we will not go to the page when the value is 'NONE'.
                    #if the value of 'KEY_URL' not NONE,we will got the page by 'navigate' function.
                    if dstURL[KEY_URL] != KEY_URL_NONE:
                        ret = ie.navigate(dstURL[KEY_URL])
                        if ret == False:
                            ie.quit()
                            #write logging
                            log_public(WEB_ERR_NO_0001 + dstURL[KEY_URL])
                            self.m_ERROR_MSG = WEB_ERR_NO_0001 + dstURL[KEY_URL]
                            return False

                        if KillCA == 'CAON':
                            #IE 8 need to click 'overridelink'
                            #IE 6 need to click 'CA authentication dialog'
                            if nVer == 8:
                                time.sleep(1)
                                ret = ie.clickLink('overridelink')
                                #encode
                                if ret == False:
                                    ie.quit()
                                    #write logging
                                    log_public(WEB_ERR_NO_0001 +
                                               dstURL[KEY_URL])
                                    self.m_ERROR_MSG = WEB_ERR_NO_0001 + dstURL[
                                        KEY_URL]
                                    return False

                                KillCA = False  #not need to kill next time open URL
                            elif nVer == 6:
                                time.sleep(1)
                                KillCA = False

                else:
                    #get line_operation.
                    dstComb = {}
                    dstComb.update(lstSub[j])

                    #if 'ASSIST' have '//',This line_operation will be ignore.
                    if dstComb[KEY_ASSIST] == KEY_COMMENT:
                        continue

                    #dispatch line_operation.include kinds(set text box, set check box,select list box,...)
                    Value = dstComb[KEY_CONTROLTYPE]
                    if Value == KEY_WEB_TYPE_TEXTBOX:
                        if ie.setTextBox(dstComb[KEY_CONTROLNAME],
                                         dstComb[KEY_CONTROLVALUE]) == False:
                            log_public(WEB_ERR_NO_0003 +
                                       dstComb[KEY_CONTROLNAME])
                            self.m_ERROR_MSG = WEB_ERR_NO_0003 + dstComb[
                                KEY_CONTROLNAME]
                            return False

                    elif Value == KEY_WEB_TYPE_CHECKBOX:
                        if self.MainCheckBox(
                                ie, dstComb[KEY_ASSIST],
                                dstComb[KEY_CONTROLNAME],
                                dstComb[KEY_CONTROLVALUE]) == False:
                            log_public(WEB_ERR_NO_0004 +
                                       dstComb[KEY_CONTROLNAME])
                            self.m_ERROR_MSG = WEB_ERR_NO_0004 + dstComb[
                                KEY_CONTROLNAME]
                            return False

                    elif Value == KEY_WEB_TYPE_LISTBOX:
                        if self.MainListBox(
                                ie, dstComb[KEY_ASSIST],
                                dstComb[KEY_CONTROLNAME],
                                dstComb[KEY_CONTROLVALUE]) == False:
                            log_public(WEB_ERR_NO_0005 +
                                       dstComb[KEY_CONTROLNAME])
                            self.m_ERROR_MSG = WEB_ERR_NO_0005 + dstComb[
                                KEY_CONTROLNAME]
                            return False

                    elif Value == KEY_WEB_TYPE_BUTTON:
                        if self.MainButton(ie, dstComb[KEY_ASSIST],
                                           dstComb[KEY_CONTROLNAME]) == False:
                            log_public(WEB_ERR_NO_0006 +
                                       dstComb[KEY_CONTROLNAME])
                            self.m_ERROR_MSG = WEB_ERR_NO_0006 + dstComb[
                                KEY_CONTROLNAME]
                            False

                    elif Value == KEY_WEB_TYPE_WAIT:
                        if self.waitEvent(dstComb[KEY_CONTROLNAME],
                                          dstComb[KEY_CONTROLVALUE]) == False:
                            log_public(WEB_ERR_NO_0007 +
                                       dstComb[KEY_CONTROLNAME])
                            self.m_ERROR_MSG = WEB_ERR_NO_0007 + dstComb[
                                KEY_CONTROLNAME]
                            return False

                    elif Value == KEY_WEB_TYPE_JAVASCRIPT:
                        if self.MainJavaScript(
                                ie, dstComb[KEY_ASSIST],
                                dstComb[KEY_CONTROLNAME]) == False:
                            log_public(WEB_ERR_NO_0008 +
                                       dstComb[KEY_CONTROLNAME])
                            self.m_ERROR_MSG = WEB_ERR_NO_0008 + dstComb[
                                KEY_CONTROLNAME]
                            return False

                    elif Value == KEY_WEB_TYPE_GROUP_CHECKBOX:
                        if self.GetGoupCheckBoxIndex(
                                ie, dstComb[KEY_CONTROLNAME]) == False:
                            log_public(WEB_ERR_NO_0009 +
                                       dstComb[KEY_CONTROLNAME])
                            self.m_ERROR_MSG = WEB_ERR_NO_0009 + dstComb[
                                KEY_CONTROLNAME]
                            return False
        #close ie after operation.
        ie.quit()