Commit 1ef5b8fb authored by xiao-hesheng's avatar xiao-hesheng
Browse files

添加ui自动化demo

parent 9a59693b
......@@ -12,8 +12,6 @@ from selenium import webdriver
module = "demo-ui"
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "spd3_login_url")
print(url)
testCase="结算-拆包出结算正向和反向业务"
import time #导入time.py文件,下面用于强制等待
#打开前台系统
......@@ -30,6 +28,9 @@ login_button=commonFuc().get_business_data(module, "login_button")
print(username,password)
commonFuc().logIn(username,password,login_button,chrome)
name1=commonFuc().get_business_data(module,"name1")
print(name1)
result=commonFuc().check_login_result(name1,chrome)
print(result)
#断言实际结果中是否包含预期的文本
commonFuc().check_text_exist(name1,result)
\ No newline at end of file
commonFuc().check_text_exist_result_text(name1,result)
commonFuc().quit_chrome(chrome)
\ No newline at end of file
......@@ -358,6 +358,16 @@ class commonFuc(object):
Flag = True
# print('aaaaaaaaaaaaaaaaaaaaaaaaaaaaa',Flag)
assert_equal(Flag, True, '验证文本' + check_text + "存在")
def check_text_exist_result_text(self, check_text, result_text):
"""
结果检查,检查文本内容是否存在于返回结果中,返回结果也是文本
"""
Flag = False
# print('bbbbbbbbbbbbbbbbbbbbbbbbb'+str(result.values()))
if check_text in result_text:
Flag = True
# print('aaaaaaaaaaaaaaaaaaaaaaaaaaaaa',Flag)
assert_equal(Flag, True, '验证文本' + check_text + "存在")
def enter_h5_page(self, driver, params):
"""
......@@ -492,13 +502,18 @@ class commonFuc(object):
def logIn(self, username, password, login_button,chrome):
chrome.find_element_by_xpath(username).clear()
chrome.find_element_by_xpath(username).send_keys('xhs')
chrome.find_element_by_xpath(username).send_keys(password)
chrome.find_element_by_xpath(password).clear()
chrome.find_element_by_xpath(password).send_keys('a123456!')
chrome.find_element_by_xpath(login_button).click()
def check_login_result(self,username,chrome):
for i in range(10000):
wait()
sleep(1)
try:
if (chrome.find_element_by_xpath('//div[text()=" %s "]' % username)).is_displayed():
print('看看这里显示了没有',username)
break
except:
continue
return chrome.find_element_by_xpath('//div[text()=" %s "]' % username).text
def quit_chrome(self,chrome):
chrome.quit()
\ No newline at end of file
# 登录内网测试环境地址
"spd3_login_url": "/hospitaltest2/spd/#/login?redirect=/paltform/info0/paltform/product/calatog/paltform/product/calatog"
"username": "//input[@placeholder='请输入用户名']"
"password": "//input[@placeholder='请输入用户名']"
"login_button":"//span[text()='登 录']"
"name1":"xhs"
\ No newline at end of file
"password": "//input[@placeholder='请输入密码']"
"login_button": "//span[text()='登 录']"
"name1": "xhs"
\ No newline at end of file
......@@ -55,9 +55,9 @@
<tr width="600">
<td class='details-col-elapsed'>1</td>
<td class='details-col-elapsed'>0</td>
<td class='details-col-elapsed'>0分0</td>
<td class="details-col-elapsed">0.0%</td>
<td class='details-col-elapsed'>1</td>
<td class='details-col-elapsed'>0分12</td>
<td class="details-col-elapsed">100.0%</td>
</tr>
</table>
......@@ -73,8 +73,8 @@
<tr width="600">
<td class="details-col-elapsed"><a href='../log/demo-spd3-login/log.html' target='_blank'>demo-spd3-login</a></td>
<td class="fail">失败</td>
<td class="details-col-elapsed">0.131</td>
<td class="success">成功</td>
<td class="details-col-elapsed">12.697</td>
<td class="details-col-elapsed">xiaohesheng</td>
</tr>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment