简体   繁体   中英

I have a config.ini file with user login details and a config read method, how do I user data from config.ini in my test case?

I have this config.ini file:

[login]
username = test123

my config reader file config_read.py :

from configparser import ConfigParser

def config_reader():
    config = ConfigParser()
    config.read('config.ini')
    username = config['login']['username']
    return username

How can I then use the username in my test case to type it in Username input field?

With selenium, what you need is send keys.

driver = webdriver.Chrome
driver.get("Your link")
driver.find_element_by_(Xpath, Id or CSS selector of your login field).send_keys("Your username")

With this, you will get your username and password possibly to your login field

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM