TA的每日心情 | 衰 2016-5-24 16:38 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
错误提示:
ERROR: test_baidu_set (__main__.Baidu)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python27\Files\baidu-2.py", line 48, in tearDown
self.assertEqual([],self.verificationErrors)
AttributeError: 'Baidu' object has no attribute 'verificationErrors'
----------------------------------------------------------------------
Ran 2 tests in 32.522s
FAILED (errors=2)
脚本:
#coding=utf-8
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re
class Baidu(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "http://www.baidu.com/"
self.verificationErrors = []
self.accept_next_alert = True
#百度搜索用例
def test_baidu_search(self):
driver=self.driver
driver.get(self.base_url+"/")
driver.find_element_by_id("kw").send_keys("selenium webdriver")
driver.find_element_by_id("su").click()
time.sleep(2)
driver.close()
#百度设置用例
def test_baidu_set(self):
driver=self.driver
#进入搜索设置页
driver.get(self.base_url+"/gaoji/preferences.html")
#设置每页搜索结果为100条
m=driver.find_element_by_name("NR")
m.find_element_by_xpath("//option[@value='50']").click()
time.sleep(2)
#保存设置的信息
driver.find_element_by_xpath("/html/body/form/div/input").click()
time.sleep(2)
#driver.switch_to_alert().accept()
alert=driver.switch_to_alert()
print(alert.text)
alert.accept()
def tearDown(self):
self.driver.quit()
self.assertEqual([],self.verificationErrors)
if __name__=="__main__":
unittest.main()
|
|