Below is an example which shows how to read a config file in python. Below is the sample config file. Just copy paste the text and save the file as config.ini [basic info] testsiteurl=https://www.google.com/ [locators] #page locators Logo_XPATH=//img[@class='logo'] Searchbar_XPATH=//*[@id='testbox'] Now its time to read the data from above config file. Below is the python code to read the data which is present in above config file. Save the file as configReader.py from configparser import ConfigParser def readConfig(section, key): config = ConfigParser() config.read("..\\conf.ini") return config.get(section, key) print(readConfig("locators","Logo_XPATH"))
Blog which contains C#, asp.net, asp.net MVC, Selenium webdriver with core java, Bootstrap, Jquery and many more