python通过configparser 读取配置文件
配置文件config.properties:
[UrlSection]
url.webdriver=http://localhost:8080
url.appserver=http://localhost
[PlatfromSection]
platform.os=windows
platform.browser=chrome
[PublishSection]
Test1.type=type1
Test1.name=testname
[CommandSection]
android.command=adb start-server
flake=python -m pip install flake8
读取文件
import configparser
import os
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
config = configparser.RawConfigParser() config.read(os.path.abspath('config.properties'))
platform_os = config.get('PlatfromSection', 'platform.os')
browser_name = config.get('PlatfromSection', 'platform.browser')
webdriver_url = config.get('UrlSection', 'url.webdriver')
app_url = config.get('UrlSection', 'url.appserver’)
browser_info = platform_os + "_" + browser_name print(browser_info)