*** Settings *** Library Selenium2Library Resource ../Menu.robot Resource ../SecurityPolicy/SourceAndDestination.robot *** Keywords *** Create-Proxy-TCP-Options [Arguments] ${tcpname} Sleep 1 Menu settings Advanced sleep 1 click element id=Advanced/advanced #点击Proxy-TCP-Options sleep 1 click element id=proxyTCPCreate #点击Create按钮 sleep 1 input text id=advancedAdd_policyName ${tcpname} #输入name sleep 1 TCPSource [Arguments] ${Source}=yes ${policytype}=null ${type1}=null ${CreateOrSearch}=null ${Add}=null ${name}=null ... ${object_name}=null ${ipclienttext1}=null ${post}=null ${Country}=null ${City}=null ... ${Protocols1}=null ${Degree}=null ${times}=null ${numbers}=null ${limits}=null ${keywordtext}=null #判断是否添加源ip,${Source}=yes,为添加源ip,否则不添加源ip run keyword if "${Source}"=="yes" run keywords sleep 1 ... AND click element xpath=/html/body/div[1]/div/div[3]/div[2]/div/div/div[1]/div[1]/div/div[2]/form/div[2]/div[1]/div/div #点击添加源ip ... AND sleep 1 ... AND Create-Source ${policytype} ${type1} ${CreateOrSearch} ${Add} ${name} ... ${object_name} ${ipclienttext1} ${post} ${Country} ${City} ... ${Protocols1} ${Degree} ${times} ${numbers} ${limits} ${keywordtext} ... ELSE log 不添加源ip TCPDestination [Arguments] ${Destination}=yes ${policytype}=null ${type1}=null ${CreateOrSearch}=null ${Add}=null ${name}=null ... ${object_name}=null ${ipclienttext1}=null ${post}=null ${Country}=null ${City}=null ... ${Protocols1}=null ${Degree}=null ${times}=null ${numbers}=null ${limits}=null ${keywordtext}=null #判断是否添加目的ip,${Destination}=yes,为添加目的ip,否则不添加目的ip sleep 1 run keyword if "${Destination}"=="yes" run keywords sleep 1 ... AND click element xpath=/html/body/div[1]/div/div[3]/div[2]/div/div/div[1]/div[1]/div/div[2]/form/div[3]/div[1]/div/div #点击添加目的ip ... AND sleep 1 ... AND Create-Destination ${policytype} ${type1} ${CreateOrSearch} ${Add} ${name} ... ${object_name} ${ipclienttext1} ${post} ${Country} ${City} ... ${Protocols1} ${Degree} ${times} ${numbers} ${limits} ${keywordtext} ... ELSE log 不添加目的ip TCPFilter [Arguments] ${Filtercreate} ${SNIname} ${Filter}=yes #判断是否添加Filter,${Filter}=yes,为添加Filter,否则不添加Filter run keyword if "${Filter}"=="yes" run keywords sleep 1 ... AND Filter-create ${Filtercreate} ${SNIname} ... ELSE log 不添加Filter Filter-create [Arguments] ${Filtercreate} ${SNIname} FOR ${i} IN @{Filtercreate} sleep 1 click element id=interceptionadd_add_filter sleep 1 run keyword if "${i}"=="SNI" run keywords sleep 1 ... AND click element id=interceptionadd_checkappshow0 ... AND Create-Object-Search ${SNIname} ${i} ... AND sleep 1 END Create-Object-Search [Arguments] ${name} ${filter} [Documentation] 调用次关键字前需要添加必填参数: ... ${name}:填入是一个列表,列表内容为object的name ... 选择search对象 sleep 1 click element xpath=//*[@id="policy_paper_left"]/div[2]/form/div[5]/div[1]/div[1]/label[contains(text(), "${filter}")]/following-sibling::div/div sleep 1 FOR ${i} IN @{name} input text xpath=//*[@id="condistions_protocol"]/div[2]/p[contains(text(), "${filter}")]/following-sibling::div[2]/div/div[1]/input ${i} sleep 1 press keys xpath=//*[@id="condistions_protocol"]/div[2]/p[contains(text(), "${filter}")]/following-sibling::div[2]/div/div[1]/input ENTER sleep 1 click element xpath=//*[@id="condistions_protocol"]/div[2]/p[contains(text(), "${filter}")]/following-sibling::div[2]/div/div[2]/div/div/ul/li[1] sleep 1 END TCP-Enable-TCP-Passthrough [Arguments] ${Enable-TCP-Passthrough}=null #判断是否开启Enable TCP Passthrough按钮,${Enable-TCP-Passthrough}=open,为开启,否则不添开启 run keyword if "${Enable-TCP-Passthrough}"=="open" run keywords sleep 1 ... AND click element xpath=//*[@id="proxytcpThrough"]/label[contains(text(), "Enable TCP Passthrough")]/following-sibling::div/div #点击Enable-TCP-Passthrough按钮开启 ... AND sleep 1 ... ELSE log 不开启 TCP-Bypass-Duplicated-Packet [Arguments] ${Bypass-Duplicated-Packet}=null #判断是否开启Bypass Duplicated Packet按钮,${Bypass-Duplicated-Packet}=open,为开启,否则不添开启 run keyword if "${Bypass-Duplicated-Packet}"=="open" run keywords sleep 1 ... AND click element xpath=//*[@id="proxyduplicatedPacket"]/label[contains(text(), "Bypass Duplicated Packet")]/following-sibling::div/div #点击Bypass-Duplicated-Packet按钮开启 ... AND sleep 1 ... ELSE log 不开启 TCP-Client-side-Parameters [Arguments] ${clickelement}=/html/body/div[1]/div/div[3]/div[2]/div/div/div[1]/div[1]/div/div[2]/form/div[9]/div[2]/div[1] ... ${ClientOverrideMSS}=null ${ClientMSSvalue}=null ${ClientNoDelay}=null ${Clientttlvalue}=null ${ClientKeepalive}=null ${ClientProbeNumber}=null ... ${ClientIdleTime}=null ${ClientInterval}=null ${ClientUserTimeout}=null sleep 1 click element id=tab-first #点击Client-side Parameters sleep 1 #判断是否开启Override MSS按钮,${Override-MSS}=open,为开启,否则不添开启 run keyword if "${ClientOverrideMSS}"=="open" run keywords sleep 1 ... AND click element xpath=${clickelement}/div/form/div/label[contains(text(), "Override MSS")]/following-sibling::div/div #点击Override-MSS按钮开启 ... AND sleep 1 ... AND input text xpath=${clickelement}/div/form/div[2]/div/div/input ${ClientMSSvalue} #输入MSS内容 ... AND sleep 1 ... ELSE log 不开启 #判断是否开启No Delay按钮,${No-Delay}=open,为开启,否则不添开启 run keyword if "${ClientNoDelay}"=="open" run keywords sleep 1 ... AND click element xpath=${clickelement}/div/form/div/label[contains(text(), "No Delay")]/following-sibling::div/div #点击No-Delay按钮开启 ... AND sleep 1 ... ELSE log 不开启 input text xpath=${clickelement}/div/form/div/label[contains(text(), "TTL")]/following-sibling::div/div/input ${Clientttlvalue} #输入ttl内容 sleep 1 #判断是否开启Keepalive按钮,${Keepalive}=open,为开启,否则不添开启 run keyword if "${ClientKeepalive}"=="open" run keywords sleep 1 ... AND click element xpath=${clickelement}/div/form/div/label[contains(text(), "Keepalive")]/following-sibling::div/div #点击Keepalive按钮开启 ... AND sleep 1 ... AND input text xpath=${clickelement}/div/form/div/div/form/div[1]/label[contains(text(), "Probe Number")]/following-sibling::div/div/input ${ClientProbeNumber} #输入Probe Number内容 ... AND sleep 1 ... AND input text xpath=${clickelement}/div/form/div/div/form/div[2]/label[contains(text(), "Idle Time")]/following-sibling::div/div/input ${ClientIdleTime} #输入Idle Time内容 ... AND sleep 1 ... AND input text xpath=${clickelement}/div/form/div/div/form/div[3]/label[contains(text(), "Interval")]/following-sibling::div/div/input ${ClientInterval} #输入Interval内容 ... AND sleep 1 ... ELSE log 不开启 input text xpath=${clickelement}/div/form/div/label[contains(text(), "User Timeout")]/following-sibling::div/div/input ${ClientUserTimeout} #输入User Timeout内容 sleep 1 TCP-Server-side-Parameters [Arguments] ${serverelement}=/html/body/div[1]/div/div[3]/div[2]/div/div/div[1]/div[1]/div/div[2]/form/div[9]/div[2]/div[2] ... ${ServerOverrideMSS}=null ${ServerMSSvalue}=null ${ServerNoDelay}=null ${Serverttlvalue}=null ${ServerKeepalive}=null ${ServerProbeNumber}=null ... ${ServerIdleTime}=null ${ServerInterval}=null ${ServerUserTimeout}=null click element id=tab-second #点击Server-side Parameters sleep 1 #判断是否开启Override MSS按钮,${Override-MSS}=open,为开启,否则不添开启 run keyword if "${ServerOverrideMSS}"=="open" run keywords sleep 1 ... AND click element xpath=${serverelement}/div/form/div/label[contains(text(), "Override MSS")]/following-sibling::div/div #点击Override-MSS按钮开启 ... AND sleep 1 ... AND input text xpath=${serverelement}/div/form/div[2]/div/div/input ${ServerMSSvalue} #输入MSS内容 ... AND sleep 1 ... ELSE log 不开启 #判断是否开启No Delay按钮,${No-Delay}=open,为开启,否则不添开启 run keyword if "${ServerNoDelay}"=="open" run keywords sleep 1 ... AND click element xpath=${serverelement}/div/form/div/label[contains(text(), "No Delay")]/following-sibling::div/div #点击No-Delay按钮开启 ... AND sleep 1 ... ELSE log 不开启 input text xpath=${serverelement}/div/form/div/label[contains(text(), "TTL")]/following-sibling::div/div/input ${Serverttlvalue} #输入ttl内容 sleep 1 #判断是否开启Keepalive按钮,${Keepalive}=open,为开启,否则不添开启 run keyword if "${ServerKeepalive}"=="open" run keywords sleep 1 ... AND click element xpath=${serverelement}/div/form/div/label[contains(text(), "Keepalive")]/following-sibling::div/div #点击Keepalive按钮开启 ... AND sleep 1 ... AND input text xpath=${serverelement}/div/form/div/div/form/div[1]/label[contains(text(), "Probe Number")]/following-sibling::div/div/input ${ServerProbeNumber} #输入Probe Number内容 ... AND sleep 1 ... AND input text xpath=${serverelement}/div/form/div/div/form/div[2]/label[contains(text(), "Idle Time")]/following-sibling::div/div/input ${ServerIdleTime} #输入Idle Time内容 ... AND sleep 1 ... AND input text xpath=${serverelement}/div/form/div/div/form/div[3]/label[contains(text(), "Interval")]/following-sibling::div/div/input ${ServerInterval} #输入Interval内容 ... AND sleep 1 ... ELSE log 不开启 sleep 1 input text xpath=${serverelement}/div/form/div/label[contains(text(), "User Timeout")]/following-sibling::div/div/input ${ServerUserTimeout} #输入User Timeout内容 sleep 1 TCP-OK sleep 1 click element id=proxyManipulationSuccess #点击OK sleep 1 TCP-Assertion [Arguments] ${name} ${search} Proxy-TCP-Options-Search ${name} ${search} #搜索刚新建的name ${text1} Get Text xpath=//*[@id="ly-table1-listcontent"]/div/div[3]/table/tbody/tr[1]/td[2]/div/div/p #获取点击后页面文本信息 Should Be Equal As Strings ${text1} ${name} #断言 Proxy-TCP-Options-Search [Arguments] ${value} ${search} sleep 1 click element id=sidebarAdvanced sleep 1 Wait Until Element Is Visible xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[3]/div[1]/div/div[1]/span/div/div/div[2]/div/div/div/input 20 click element xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[3]/div[1]/div/div[1]/span/div/div/div[2]/div/div/div/input #点击搜索框 sleep 1 #判断是使用name搜索还是id搜索 run keyword if "${search}"=="Name" run keywords sleep 1 ... AND click element xpath=/html/body/div/div[1]/div[1]/ul/li[3] //*[@id="app"]/div/div[3]/div[2]/div/div[3]/div[1]/div/div[1]/span/div/div/div[2]/div/div[1]/div[3]/div/input ... AND input text xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[3]/div[1]/div/div[1]/span/div/div/div[2]/div/div[1]/div[3]/div/input ${value} ... ELSE IF "${search}"=="ID" run keywords sleep 1 ... AND click element xpath=/html/body/div/div[1]/div[1]/ul/li[2] ... AND input text xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[3]/div[1]/div/div[1]/span/div/div/div[2]/div/div[1]/div[3]/div/input ${value} ... AND sleep 1 click element xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[3]/div[1]/div/div[1]/span/div/i #点击搜索按钮 sleep 1 Run Keyword And Ignore Error click element xpath=//*[@id="ly-table1-listcontent"]/div/div[3]/table/tbody/tr[1] #点击搜索到的列表 sleep 1 Delete-Proxy-estimate [Arguments] ${securityname} run keyword if "${securityname}"!="null" run keywords sleep 1 ... AND Delete-Proxy ${securityname} ... ELSE log go on Delete-Proxy [Arguments] ${securityname} Menu settings Advanced sleep 2 Proxy-TCP-Options-Search ${securityname} Name sleep 2 Run Keyword And Ignore Error click element id=proxyTCPDel sleep 1 Run Keyword And Ignore Error click element xpath=/html/body/div/div/div[3]/button[2] sleep 1 Delete-object-estimate [Arguments] ${obj} run keyword if "${obj}"!="null" run keywords sleep 1 ... AND Delete-object ${obj} ... ELSE log go on Delete-object [Arguments] ${obj} FOR ${num} ${key} IN ENUMERATE @{obj} Forname ${obj}[${key}] ${key} END Forname [Arguments] ${objectname} ${key} FOR ${i} IN @{objectname} Menu objects ${key} sleep 2 click element xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[1]/div[1]/span/div/div/div[2]/div/div/div/input #点击输入框 sleep 2 click element xpath=/html/body/div/div[1]/div[1]/ul/li[3] #点击name为搜索类型 sleep 2 input text xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[1]/div[1]/span/div/div/div[2]/div/div[1]/div[3]/div/input ${i} #输入搜索内容 sleep 2 click element xpath=//*[@id="app"]/div/div[3]/div[2]/div/div[1]/div[1]/span/div/i #点击搜索按钮 sleep 2 Run Keyword And Ignore Error click element xpath=//*[@id="ly-table1-listcontent"]/div/div[3]/table/tbody/tr[1]/td[1]/div/div/span #选择搜索到的列表 sleep 2 sleep 1 Run Keyword And Ignore Error click element id=objectDel #点击删除按钮 sleep 1 Run Keyword And Ignore Error click element xpath=/html/body/div/div/div[3]/button[2] sleep 1 END