|
import time
import ddt
import unittest2
from func.csvFileManager2 import reader
from test_case.BaseTestCase import BaseTestCase
@ddt.ddt
class BaiduTestCase(BaseTestCase):
keyword = reader("baidu_test_cases.csv")
@ddt.data(*keyword)
def test_baidu(self,row):
driver =self.driver
driver.get("https://www.baidu.com/")
driver.find_element_by_id("kw").send_keys(row[0])
driver.find_element_by_id("kw").submit()
time.sleep(2)
for i in range(1, 11):
result_title = driver.find_element_by_css_selector("div#content_left > div[id='" + str(i) + "'] > h3 > a").text
print(result_title)
self.assertIn(row[0], result_title)
if __name__ == '__main__':
unittest2.main() |
|