1、提交登录限制关键字和用例2、提交解决登录限制ip修改和删除按钮不可定位问题
This commit is contained in:
@@ -15,12 +15,20 @@ User-Edit-003
|
|||||||
Login_Restrictions Login-Restrictions=close
|
Login_Restrictions Login-Restrictions=close
|
||||||
|
|
||||||
User-Edit-004
|
User-Edit-004
|
||||||
|
#执行此用例后,需要执行User-Edit-005和User-Edit-delete-006,以保证下次执行时的环境为正确环境
|
||||||
#用户修改Login Restrictions 其他保持不动,新建ip白名单 ipv4最小值和Cidr最小值,ipv4最大值和Cidr最大值,中间值
|
#用户修改Login Restrictions 其他保持不动,新建ip白名单 ipv4最小值和Cidr最小值,ipv4最大值和Cidr最大值,中间值
|
||||||
${list-ip} Create list 0.0.0.0/0 255.255.255.255/32 199.199.199.199/22
|
${list-ip} Create list 0.0.0.0/0 255.255.255.255/32 199.199.199.199/22 233.233.233.224/32
|
||||||
Login_Restrictions Login-Restrictions=open ip-type=create ip-value=${list-ip}
|
Login_Restrictions Login-Restrictions=open ip-type=create ip-value=${list-ip}
|
||||||
|
|
||||||
User-Edit-005
|
User-Edit-005
|
||||||
|
#执行此用例前,取药先执行User-Edit-004用例以保证测试数据存在
|
||||||
#用户修改Login Restrictions 其他保持不动,修改ip白名单 ipv4最小值和Cidr最小值,ipv4最大值和Cidr最大值,中间值
|
#用户修改Login Restrictions 其他保持不动,修改ip白名单 ipv4最小值和Cidr最小值,ipv4最大值和Cidr最大值,中间值
|
||||||
${list-ip} Create list 192.168.99.1/24
|
${list-ip} Create list 233.233.233.224/32
|
||||||
${list-ip1} Create list 0.0.0.0/15
|
${list-ip1} Create list 233.233.233.255/32
|
||||||
Login_Restrictions ip-type=edit ip-value=${list-ip} ip-value1=${list-ip1}
|
Login_Restrictions ip-type=edit ip-value=${list-ip} ip-value1=${list-ip1}
|
||||||
|
|
||||||
|
User-Edit-delete-006
|
||||||
|
#执行此用例前,需要先执行User-Edit-004用例和User-Edit-005以保证测试数据存在
|
||||||
|
#用户修改Login Restrictions 其他保持不动,修改ip白名单 ipv4最小值和Cidr最小值,ipv4最大值和Cidr最大值,中间值
|
||||||
|
${list-ip} Create list 233.233.233.255/32 199.199.199.199/22 255.255.255.255/32 0.0.0.0/0
|
||||||
|
Login_Restrictions ip-type=delete ip-value=${list-ip}
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ Resource ../objects/ObjectPages.robot
|
|||||||
|
|
||||||
*** Keywords ***
|
*** Keywords ***
|
||||||
Login_Restrictions
|
Login_Restrictions
|
||||||
[Arguments] ${Login-Restrictions}=1 ${ip-type}=1 ${ip-value}=[192.2.2.2/24] ${ip-value1}=[192.2.2.2/24] ${Maximum-Login-Attemepts}=1 ${Maximum-Login-Attemepts-valuie}=5 ${Lock-Time}=1 ${Lock-Time-valuie}=60
|
[Arguments] ${Login-Restrictions}=1 ${ip-type}=1 ${ip-value}=[192.2.2.2/24] ${ip-value1}=[192.2.2.2/24] ${Maximum-Login-Attemepts}=1 ${Maximum-Login-Attemepts-valuie}=5
|
||||||
|
... ${Lock-Time}=1 ${Lock-Time-valuie}=60
|
||||||
sleep 1
|
sleep 1
|
||||||
Menu administration Login Restrictions #点击菜单Login Restrictions
|
Menu administration Login Restrictions #点击菜单Login Restrictions
|
||||||
sleep 1
|
sleep 1
|
||||||
@@ -16,11 +17,11 @@ Login_Restrictions
|
|||||||
run keyword if "${Login-Restrictions}"=="open" and "${class}"=="el-switch is-checked" log 按钮为开启状态,不进行操作
|
run keyword if "${Login-Restrictions}"=="open" and "${class}"=="el-switch is-checked" log 按钮为开启状态,不进行操作
|
||||||
run keyword if "${Login-Restrictions}"=="open" and "${class}"=="el-switch" Run Keywords log 按钮为关闭状态,需要点击开启
|
run keyword if "${Login-Restrictions}"=="open" and "${class}"=="el-switch" Run Keywords log 按钮为关闭状态,需要点击开启
|
||||||
... AND sleep 1
|
... AND sleep 1
|
||||||
... AND click element link=//*[@id="policy_Manipulation2"]/div/div[2]/div/div/form/div[1]/div/div
|
... AND click element xpath=//*[@id="policy_Manipulation2"]/div/div[2]/div/div/form/div[1]/div/div
|
||||||
run keyword if "${Login-Restrictions}"=="close" and "${class}"=="el-switch is-checked" Run Keywords log 按钮为开启状态,需要点击关闭
|
run keyword if "${Login-Restrictions}"=="close" and "${class}"=="el-switch is-checked" Run Keywords log 按钮为开启状态,需要点击关闭
|
||||||
... AND sleep 1
|
... AND sleep 1
|
||||||
... AND click element xpath=//*[@id="policy_Manipulation2"]/div/div[2]/div/div/form/div[1]/div/div
|
... AND click element xpath=//*[@id="policy_Manipulation2"]/div/div[2]/div/div/form/div[1]/div/div
|
||||||
run keyword if "${Login-Restrictions}"=="close" and "${class}"=="el-switch" log 按钮为关闭状态,不进行操作
|
run keyword if "${Login-Restrictions}"=="close" and "${class}"=="el-switch" log 按钮为关闭状态,不进行操作
|
||||||
sleep 1
|
sleep 1
|
||||||
#判断操作类型
|
#判断操作类型
|
||||||
run keyword if "${ip-type}"=="create" Ip-Create ${ip-value}
|
run keyword if "${ip-type}"=="create" Ip-Create ${ip-value}
|
||||||
@@ -30,8 +31,8 @@ Login_Restrictions
|
|||||||
run keyword if "${Lock-Time}"=="input" input text xpath=//*[@id="policy_Manipulation2"]/div/div[2]/div/div/form/div[3]/div/div/input ${Lock-Time-valuie}
|
run keyword if "${Lock-Time}"=="input" input text xpath=//*[@id="policy_Manipulation2"]/div/div[2]/div/div/form/div[3]/div/div/input ${Lock-Time-valuie}
|
||||||
sleep 1
|
sleep 1
|
||||||
click element id=wanAdd_ok
|
click element id=wanAdd_ok
|
||||||
sleep 1
|
Wait Until Element Is Visible //p[.="Success"] 20
|
||||||
${Text} get text xpath=/div/p
|
${Text} get text //p[.="Success"]
|
||||||
sleep 2
|
sleep 2
|
||||||
Should Be Equal As Strings ${Text} Success #断言
|
Should Be Equal As Strings ${Text} Success #断言
|
||||||
|
|
||||||
@@ -44,40 +45,43 @@ Ip-Create
|
|||||||
\ click element id=temporary_form
|
\ click element id=temporary_form
|
||||||
\ sleep 1
|
\ sleep 1
|
||||||
\ input text id=statusInputedit ${ip}[${i}]
|
\ input text id=statusInputedit ${ip}[${i}]
|
||||||
\ sleep 1
|
\ sleep 1
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
IP-search
|
IP-search
|
||||||
[Arguments] ${ip}
|
[Arguments] ${ip}
|
||||||
sleep 1
|
sleep 1
|
||||||
input text id=object_ip_search ${ip}
|
input text id=object_ip_search ${ip}
|
||||||
sleep 1
|
sleep 1
|
||||||
press keys id=object_ip_search ENTER
|
press keys id=object_ip_search ENTER
|
||||||
|
|
||||||
IP-Edit
|
IP-Edit
|
||||||
[Arguments] ${ip} ${new_ip}
|
[Arguments] ${ip} ${new_ip}
|
||||||
${j} get length ${ip}
|
${j} get length ${ip}
|
||||||
|
Import Library ${path}variable/LoginRestrictions.py #引用自定义python文件,获取ip索引
|
||||||
sleep 1
|
sleep 1
|
||||||
: FOR ${i} IN RANGE ${j}
|
: FOR ${i} IN RANGE ${j}
|
||||||
\ sleep 1
|
\ sleep 1
|
||||||
\ IP-search ${ip}[${i}]
|
\ IP-search ${ip}[${i}]
|
||||||
\ sleep 1
|
|
||||||
\ Click Element //div[text()="${ip}[${i}]"] #点击修改按钮
|
|
||||||
\ sleep 1
|
\ sleep 1
|
||||||
\ input text id=statusInputedit ${new_ip} #输入修改后的ip
|
\ ${index} index1 ${ip}[${i}] #获取ip所在列表的索引值
|
||||||
|
\ Click Element id=editForm${index} #点击修改按钮
|
||||||
|
\ sleep 1
|
||||||
|
\ input text id=statusInputedit ${new_ip} #输入修改后的ip
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
|
|
||||||
IP-Delete
|
IP-Delete
|
||||||
[Arguments] ${ip}
|
[Arguments] ${ip}
|
||||||
${j} get length ${ip}
|
${j} get length ${ip}
|
||||||
|
Import Library ${path}variable/LoginRestrictions.py
|
||||||
sleep 1
|
sleep 1
|
||||||
: FOR ${i} IN RANGE ${j}
|
: FOR ${i} IN RANGE ${j}
|
||||||
\ sleep 1
|
\ sleep 1
|
||||||
\ IP-search ${ip}[${i}]
|
\ IP-search ${ip}[${i}]
|
||||||
\ sleep 1
|
\ sleep 1
|
||||||
\ click element xpath=/html/body/div[1]/div/div[3]/div[2]/div/div[1]/div/div[2]/div/div/form/div[2]/div/div[1]/div[2]/div[1]/div/div/div/div/div[2]/i[2] #点击删除按钮
|
\ sleep 1
|
||||||
|
\ ${index} index1 ${ip}[${i}]
|
||||||
|
\ sleep 1
|
||||||
|
\ click element id=delForm${index} #点击删除按钮
|
||||||
\ sleep 1
|
\ sleep 1
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
38
05-Other/variable/LoginRestrictions.py
Normal file
38
05-Other/variable/LoginRestrictions.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/user/bin/python
|
||||||
|
#-*-coding:utf-8-*-
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
#获取密码加密信息
|
||||||
|
def encryptpwd():
|
||||||
|
url1 = "http://192.168.44.71:8080/v1/user/encryptpwd"
|
||||||
|
content = {"password":"1"}
|
||||||
|
web = requests.get(url=url1,params=content)
|
||||||
|
#print(web.text)
|
||||||
|
ty = web.text
|
||||||
|
a = json.loads(ty)
|
||||||
|
#print(a["data"]['encryptpwd'])
|
||||||
|
encryptpwd = a["data"]['encryptpwd']
|
||||||
|
return encryptpwd
|
||||||
|
#获取token
|
||||||
|
def token():
|
||||||
|
url2 = "http://192.168.44.71:8080/v1/user/login"
|
||||||
|
content = {"username":"lyf","password":encryptpwd(),"authMode":1}
|
||||||
|
web = requests.post(url=url2,params=content)
|
||||||
|
#print(web.text)
|
||||||
|
ty1 = web.text
|
||||||
|
a1 = json.loads(ty1)
|
||||||
|
token = a1["data"]["token"]
|
||||||
|
return token
|
||||||
|
#获取索引值
|
||||||
|
def index1(id):
|
||||||
|
url3 = "http://192.168.44.71/v1/user/login/restictions"
|
||||||
|
headers = {"Content-Type":"application/json;charset=UTF-8","Authorization":token()}
|
||||||
|
web = requests.get(url=url3,headers=headers)
|
||||||
|
#print(web.text)
|
||||||
|
ty2 = web.text
|
||||||
|
a2 = json.loads(ty2)
|
||||||
|
loginAddrWhitelist = a2["data"]["list"][0]["loginAddrWhitelist"]
|
||||||
|
index2=loginAddrWhitelist.index(id)
|
||||||
|
return index2
|
||||||
|
if __name__ == '__main__':
|
||||||
|
index1(id)
|
||||||
Reference in New Issue
Block a user