网页界面自动化测试

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = 'hshao'

from selenium.webdriver.common.by import By
from webui import WebElement

#=======================================================================
# FuncName:MapElement
# Desc:
# 
# Para:
# Return:
# Date: 2014-05-31 18:03
# Author: hshao
#=======================================================================
class MapElement(WebElement):
    plan_menu = (By.XPATH,'//li[@data-dojo-attach-point="planTab"]/a')
    import_btn = (By.XPATH, '''//button[@data-dojo-attach-point="btnImportMap"]''')
    import_from = (By.XPATH, '''//div[@data-dojo-attach-point="importForm"]''')
    choose_btn = (By.XPATH, '''//span[@data-dojo-attach-point="containerNode"]''')
    choose_event = (By.XPATH, '''///span[@data-dojo-attach-event="ondijitclick:_onClick"]''')
    file_name = (By.XPATH, '''//span[@data-dojo-attach-point="uploadFileName"]''')
    input_file = (By.XPATH, '''//div[@data-dojo-attach-point="importFileUploader"]/span/input[1]''')
    inport_btn_in_popup_window = (By.XPATH,'//button[@data-dojo-attach-point="btnImport"]')
    
    
class aaa(WebElement):
    pass
#=======================================================================
# FuncName:RescaleFloorSize
# Desc:
# 
# Para:
# Return:
# Date: 2015-05-31 17:32
# Author: junma
#=======================================================================
class RescaleFloorSize(WebElement):
    Button_Set = (By.XPATH,'//div[@data-dojo-attach-point="settings"]')
    Table_Setting = (By.XPATH,'//div[@aria-label="dijit_Menu_7"]')
    Button_Rescale = (By.XPATH,'//tr[@aria-label="Rescale Plan "]')
    Button_Apply = (By.XPATH,'//button[@data-dojo-attach-point="btnApply"]')
    
    Input_Width = (By.XPATH,'//input[@data-dojo-attach-point="width"]')
    Input_Height = (By.XPATH,'//input[@data-dojo-attach-point="height"]')
    
    Button_DpDwList = (By.XPATH,'//div[@class="unit"]/descendant::a[@class="chzn-single"]/div/b')
    Option_Feet = (By.XPATH,'//ul/li[text()="feet"]')
    Option_List = ("Device Labels ","Rescale Plan ","Show Grid ","Change Plan Units ","Global Settings ","Planning Tool ")

#=======================================================================
# FuncName:HeatMap
# Desc:
# 
# Para:
# Return:
# Date: 2015-05-31 18:03
# Author: junma
#=======================================================================
class HeatMap(WebElement):
    Button_HeatMap = (By.XPATH, '//dd[text()="View Heat Map"]')
    Map_layer = (By.XPATH, '//div[@class="map-layers"]')
    But_Auto_Place = (By.XPATH, '//button[@data-dojo-attach-point="btnAutoPlace"]')
    But_Auto_Place_More = (By.XPATH, '//a[@data-dojo-attach-point="autoPlaceMore"]')
    But_Auto_Place2 = (By.XPATH, '//button[@data-dojo-attach-point="btnAutoPlace2"]')
    
    But_Add_Device = (By.XPATH, '//button[@data-dojo-attach-point="btnAddDevice"]')
    But_Add_Device_More = (By.XPATH, '//a[@data-dojo-attach-point="addDevicesMore"]')
    
    Tab_Multi = (By.XPATH, '//dd[text()="%s"]')  #Plan Devices
    But_Sel_All_Device = (By.XPATH, '//a[@data-dojo-attach-point="selectAllDevice"]')
    But_Del_Device = (By.XPATH, '//a[@data-dojo-attach-point="delDevices"]')
    But_Yes = (By.XPATH, '//a[@data-dojo-attach-point="btnYes"]')
    
    Heatmap_Type = (By.XPATH, '//div[@data-dojo-attach-point="heatToolItems"]/descendant::ul/li[text()="%s"]') # 2.4 GHz or 5 Ghz or channel type or heatmap type
  
#=======================================================================
# ClassName:GlobalSettingElm
# Desc:This class element is included the element that used to set Global settings
# 
# Para:
# Return:
# Date: 2015-05-21 18:17
# Author: junma
#=======================================================================
class GlobalSettingElm(WebElement):
    Input_Interval = (By.XPATH,'//[@data-dojo-attach-point="pollingInterval"]')
    
    
    Modify_Save = (By.XPATH,'//a[@data-dojo-attach-point ="btnSave"]')
    Modify_Cancle = (By.XPATH,'//a[@data-dojo-attach-point ="btnCancle"]')
    
    Button_Set = (By.XPATH,'//div[@data-dojo-attach-point="settings"]')
    
    Adj_Rssi_threshold = (By.XPATH,'//label[text()="RSSI Threshold for Location"]/parent::div/div/div/a/div/b')
    Locatin_Threshold = (By.XPATH, '//label[text()="RSSI Threshold for Location"]/parent::div/div/div/div/ul[%d]')
    
    Rssi_Range_1 = (By.XPATH,'//label[text()="RSSI range for calibration"]/parent::div/div/div[%1]/a/div/b')
    vlaue_range_low = (By.XPATH,'//label[text()="RSSI range for calibration"]/parent::div/div/div[1]/div/ul/li[%d]')
    Rssi_Range_2 = (By.XPATH,'//label[text()="RSSI range for calibration"]/parent::div/div/div[2]/a/div/b')
    vlaue_range_high = (By.XPATH,'//label[text()="RSSI range for calibration"]/parent::div/div/div[2]/div/ul/li[%d]')
    
    Opacity_Background = (By.XPATH,'//span[text()="Opacity of Background"]/parent::div/div[1]/a/div/b')
    Background_vlaue = (By.XPATH,'//span[text()="Opacity of Background"]/parent::div/div[1]/div/ul/li[%d]')
    
    Opacity_Coverage = (By.XPATH,'//span[text()="Opacity of Background"]/parent::div/div[2]/a/div/b')
    coverage_value = (By.XPATH,'//span[text()="Opacity of Background"]/parent::div/div[2]/div/ul/li[%d]')
    
    Opacity_Wall = (By.XPATH,'//span[text()="Opacity of Background"]/parent::div/div[3]/a/div/b')
    wall_value = (By.XPATH,'//span[text()="Opacity of Background"]/parent::div/div[3]/div/ul/li[%d]')
    
    Min_AP_ForLocation = (By.XPATH,'//span[text()="Minimum"]/parent::div/div/a/div/b')
    Ap_num = (By.XPATH,'//span[text()="Minimum"]/parent::div/div/div/ul/li[%d]')
    
    Recent_Report = (By.XPATH,'//input[@data-dojo-attach-point="recentlyReported"]')
    Interval_Report = (By.XPATH,'//input[@data-dojo-attach-point="intervalReported"]')
    
    Input_RepInt = (By.XPATH,'//input[@data-dojo-attach-point="locationWindow"]') 
    
    Select_Item_Summary = (By.XPATH,'//input[@data-dojo-attach-point="summaryFlag"]')
    Select_mesh_ethernet = (By.XPATH,'//input[@data-dojo-attach-point="neighborRssiFlag"]')
    Select_Calibrate_Heatmap = (By.XPATH, '//input[@data-dojo-attach-point="calibrateHeatMap"]')
    Select_Heatmap_Location = (By.XPATH, '//input[@data-dojo-attach-point="useHeatMap"]')
    Select_periVal = (By.XPATH, '//input[@data-dojo-attach-point="periVal"]')


#=======================================================================
# FuncName:LocationElm
# Desc:
# 
# Para:
# Return:
# Date: 2015-05-21 18:03
# Author: junma
#=======================================================================  
###====================================Location Operation Xpath=============================
class LocationElm(WebElement):
    Button_Plan = (By.XPATH, '''//li[@data-dojo-attach-point="planTab"]/a''')
    
    Button_import_map = (By.XPATH, '''//button[@data-dojo-attach-point="importMapBtn"]''')
    Button_AddLocation = (By.XPATH, '''//button[@data-dojo-attach-point="addLocationBtn"]''')
    Button_Edit_map = (By.XPATH, '''//dd[@data-level="0"]/descendant::span[@title="Edit"]''')
    Button_save = (By.XPATH, '''//button[@data-dojo-attach-point ="btnSaveLocation"]''')
    Button_save_build = (By.XPATH,'''//button[@data-dojo-attach-point ="btnSaveBuilding"]''')
    Button_Yes = (By.XPATH, '''//button[@data-dojo-attach-point="yesBtn"]''')
    Button_ExportMap = (By.XPATH,'//div/a[@data-dojo-attach-point="btnExport"]')
    #first will be replaced by floor or building or location name,second will be replaced by function of the button,such an more,move,delete,and export
    Button_Multi_Func = (By.XPATH, '''//div[@title="%s"]/parent::dd/div/span[@title="%s"]''')
    
    Button_expand = (By.XPATH,'''//div[@title="%s"]/parent::dd/span''') #%s should be replaced by name,such as "aerohive"
    Button_Fold =(By.XPATH, '''//dd[@class="generic level%d level-close"]/span''')
    
    Input_locationname = (By.XPATH, '''//input[@data-dojo-attach-point ="locationName"]''')
    Input_buildingname = (By.XPATH,'''//input[@data-dojo-attach-point ="buildingName"]''')
    Input_locatinaddress = (By.XPATH, '''//input[@data-dojo-attach-point ="locationAddress"]''')
    Input_buildingaddr = (By.XPATH,'''//input[@data-dojo-attach-point ="buildingAddress"]''')
    
    Menu_Location_expand = (By.XPATH, '''//div/a[@class="chzn-single chzn-single-with-drop"]''')
    Menu_Location = (By.XPATH, '''//div[@data-dojo-attach-point="assoWithInLocation"]/descendant::div/b''')
    # Menu_item = (By.XPATH,'''//div/ul/li[@id="ah_util_Chosen_%d_chzn_o_%d"]''')     #%d should be replaced when use it.(counter,order)
    Menu_FindItembyName = (By.XPATH,'''//div[@data-dojo-attach-point="assoWithInLocation"]/descendant::li[text()="%s"]''')  #%s should be replaced by name of associated place
    check_title = (By.XPATH, '//div[@title="%s"]')
    
    choose_btn = (By.XPATH, '''//span[@data-dojo-attach-point="containerNode"]''')
    choose_event = (By.XPATH, '''///span[@data-dojo-attach-event="ondijitclick:_onClick"]''')
    

#=====================================End============================================================
class ImportFile(WebElement):
    Button_level = (By.XPATH,'//div[@title="%s"]')
    Button_Choose_File = (By.XPATH,'//span[@class="dijitReset dijitInline dijitButtonNode"]')
    input_file = (By.XPATH,'//div[@data-dojo-attach-point="importFileUploader"]/span/input[1]')
    file_name = (By.XPATH, '''//span[@data-dojo-attach-point="uploadFileName"]''')
    File_path_f = "E:\Files\JunMa\Downloads\floor6_1422305608204.xml"
    Button_Import = (By.XPATH,'//button[@data-dojo-attach-point="btnImport"]')
    
    
class DeviceLabel(WebElement):
    B_Device_lable = (By.XPATH,'//tr[@aria-label="Device Labels ')
    B_Selc = (By.XPATH,'//tr[@aria-label="%s"]')
    Selection_List = ("Host Name ","Channel / Power ","Device Type ","None ")
    Device_label = (By.XPATH,'//div[@class="leaf-label"]')