Java教程

参数化

本文主要是介绍参数化,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
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()
这篇关于参数化的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!