首页 > 其他分享 >pytest数据驱动 pandas

pytest数据驱动 pandas

时间:2022-11-01 16:46:59浏览次数:83  
标签:__ self driver pytest pf 驱动 pandas

pytest数据驱动 pandas

主要过程:用pandas读取excel里面的数据,然后进行百度查询,并断言

 

pf = pd.read_excel('data_py.xlsx', usecols=[1,2])

print(pf.values)

输出:

[[‘听妈妈的话’ ‘周杰伦’]
[‘遇见’ ‘孙燕姿’]
[‘伤心太平洋’ ‘任贤齐’]]

 

pf = pd.read_excel('data_py.xlsx', usecols=[1,2])
data_res = pf.values

 

@pytest.mark.parametrize('name, result_content', data_res)
class Test_py(object):
  def setup(self):
    self.driver = webdriver.Chrome()
    self.driver.get("https://www.baidu.com")
    time.sleep(1)


  def test_q(self, name, result_content):
    self.driver.find_element_by_id("kw").send_keys(name)
    time.sleep(1)
    self.driver.find_element_by_id('su').click()
    time.sleep(2)
    #断言搜索结果是否包含对应的内容
    assert  result_content  in  self.driver.page_source

  def teardown(self):
    self.driver.quit()

if __name__=="__main__":
  pytest.main()

 

标签:__,self,driver,pytest,pf,驱动,pandas
From: https://www.cnblogs.com/111testing/p/16848225.html

相关文章