*** Settings *** Library Selenium2Library *** Keywords *** ChangePassword [Arguments] ${passwd}=null ${Required-Password-Change}=close ${day}=100 Mouse Hover xpath=//*[@id="app"]/div/div[1]/div[2]/div/span/div/span #鼠标悬浮到用户名 sleep 0.5 click element id=editInfo #点击密码修改 sleep 1 #判断是否修改密码 run keyword if "${passwd}"!="null" Run Keywords sleep 1 ... AND input text xpath=//*[@id="app"]/div/div[3]/div[1]/div/div/div[1]/div/div/div[1]/div/div/div[1]/div[2]/form/div[3]/div/div/input ${passwd} ... AND sleep 1 ... AND input text xpath=//*[@id="app"]/div/div[3]/div[1]/div/div/div[1]/div/div/div[1]/div/div/div[1]/div[2]/form/div[4]/div/div/input ${passwd} ... AND sleep 1 ${class}= Get Element Attribute xpath=//*[@id="app"]/div/div[3]/div[1]/div/div/div[1]/div/div/div[1]/div/div/div[1]/div[2]/form/div[5]/div/div class #获取Required-Password-Change按钮的class元素的值 #通过元素的值判断按钮是开启状态还是关闭状态 run keyword if "${Required-Password-Change}"=="open" and "${class}"=="el-switch is-checked" Run Keywords log 按钮为开启状态,不进行操作 ... AND sleep 1 ... AND input text xpath=//*[@id="app"]/div/div[3]/div[1]/div/div/div[1]/div/div/div[1]/div/div/div[1]/div[2]/form/div[6]/div/div/input ${day} ... AND sleep 1 run keyword if "${Required-Password-Change}"=="open" and "${class}"=="el-switch" Run Keywords log 按钮为关闭状态,需要点击开启 ... AND sleep 1 ... AND click element xpath=//*[@id="app"]/div/div[3]/div[1]/div/div/div[1]/div/div/div[1]/div/div/div[1]/div[2]/form/div[5]/div/div ... AND sleep 1 ... AND input text xpath=//*[@id="app"]/div/div[3]/div[1]/div/div/div[1]/div/div/div[1]/div/div/div[1]/div[2]/form/div[6]/div/div/input ${day} ... AND sleep 1 run keyword if "${Required-Password-Change}"=="close" and "${class}"=="el-switch is-checked" Run Keywords log 按钮为开启状态,需要点击关闭 ... AND sleep 1 ... AND click element xpath=xpath=//*[@id="app"]/div/div[3]/div[1]/div/div/div[1]/div/div/div[1]/div/div/div[1]/div[2]/form/div[5]/div/div run keyword if "${Required-Password-Change}"=="close" and "${class}"=="el-switch" log 按钮为关闭状态,不进行操作 sleep 1 click element xpath=//*[@id="app"]/div/div[3]/div[1]/div/div/div[1]/div/div/div[1]/div/div/div[2]/button[1] #点击OK提交 Wait Until Element Is Visible //p[.="Success"] 20 ${Text} get text //p[.="Success"] sleep 2 Should Be Equal As Strings ${Text} Success #断言