参数化


from time import sleep
import pandas as pd
import pytest
from selenium import webdriver
from selenium.webdriver.common.by import By




result_data = pd.read_excel('wenjian.xlsx',usecols=[0,1])
data_res = result_data.values
@pytest.mark.parametrize('username,password',data_res)
class Test_Blog_garden():
def setup_class(self):
self.driver = webdriver.Chrome()
self.driver.get('https://i.cnblogs.com/posts')
self.driver.maximize_window()

def teardown_class(self):
sleep(5)
self.driver.close()
self.driver.quit()

def test_login(self,username,password):
self.driver.implicitly_wait(3)
self.driver.find_element(By.XPATH, '//*[@id="mat-input-0"]').send_keys(username)
self.driver.find_element(By.XPATH, '//*[@id="mat-input-1"]').send_keys(password)
self.driver.find_element(By.XPATH, '/html/body/app-root/app-sign-in-layout/'
'div/div/app-sign-in/app-content-container/div/div/div/form/div/button').click()

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

原创文章,作者:506227337,如若转载,请注明出处:https://blog.ytso.com/244683.html

(0)
上一篇 2022年4月17日
下一篇 2022年4月17日

相关推荐

发表回复

登录后才能评论