TA的每日心情 | 奋斗 2017-7-21 16:51 |
---|
签到天数: 4 天 连续签到: 4 天 [LV.2]测试排长
|
使用xml文件做“数字驱动测试”
代码如下:
- info.xml[code]<?xml version="1.0" encoding="utf-8"?>
- <catalog>
- <explain>中国移动139邮箱</explain>
- <url>http://mail.10086.cn/</url>
- <all_null username="" password="">请输入帐号</all_null>
- <pawd_null username="testingwtb" password="">请输入邮箱密码</pawd_null>
- <user_null username="" password="a123456">请输入帐号</user_null>
- <yes username="15919825333" password="******">15919825333</yes>
- <error username="xxx" password="xxx">帐号或密码错误</error>
- </catalog>
复制代码
py文件如下:
- #coding:UTF-8
- from selenium import webdriver
- import unittest
- from xml.dom import minidom
- dom = minidom.parse('C:\\Users\\Administrator\\Desktop\\info.xml')
- root = dom.documentElement
- class Test_139(unittest.TestCase):
- def setUp(self):
- self.driver = webdriver.Ie()
- self.driver.implicitly_wait(30)
- logns = root.getElemntByTagName('url')
- self.url =logns[0].firstChild.data
- self.verificationErrors= []
- def test_all_null(self):
- driver = self.driver
- driver.get(self.url)
- longs = root.getElemntByTagName('all_null')
- username = longs[0].getAttribute('username')
- password = longs[0].getAttribute('password')
- Text = longs[0].firstChild.data
- driver.find_element_by_name('UserName').send_keys(username)
- driver.find_element_by_class_name('Password').send_keys(password)
- driver.find_element_by_id('loginBtn').click()
- test = driver.find_element_by_id('tip_user_msg').text
- self.assertEqual(test, Text)
-
-
- if __name__ == '__main__':
- unittest.main()
复制代码
运行后报错了,如下:
- Traceback (most recent call last):
- File "D:\Escplise\workspace\Pytest\src\test001\test\test003.py", line 7, in <module>
- dom = minidom.parse('C:\\Users\\Administrator\\Desktop\\info.xml')
- File "C:\Python27\lib\xml\dom\minidom.py", line 1918, in parse
- return expatbuilder.parse(file)
- File "C:\Python27\lib\xml\dom\expatbuilder.py", line 924, in parse
- result = builder.parseFile(fp)
- File "C:\Python27\lib\xml\dom\expatbuilder.py", line 207, in parseFile
- parser.Parse(buffer, 0)
- xml.parsers.expat.ExpatError: not well-formed (invalid token): line 3, column 9
复制代码
,小白一个,不知道错误原因,求大神帮助!!! |
|