'system_setting_xpath') log_record_xpath = excuteCFG.GetConfig().getSystemSetting( 'log_record_xpath') log_record_pages_count = excuteCFG.GetConfig().getSystemSetting( 'log_record_pages_count') log_record_pages_switch_xpath = excuteCFG.GetConfig().getSystemSetting( 'log_record_pages_switch_xpath') log_record_goto_css = excuteCFG.GetConfig().getSystemSetting( 'log_record_goto_css') log_record_goto_btn_css = excuteCFG.GetConfig().getSystemSetting( 'log_record_goto_btn_css') except Exception as e: baseinfo.getErrorInfo('获取配置文件出错') print e class SystemLogRecord(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() self.driver.maximize_window() self.driver.implicitly_wait(waittime) self.verificationErrors = [] self.accept_next_alert = True self.driver.get(url) self.driver.find_element_by_xpath(username_xpath).send_keys(username) self.driver.implicitly_wait(waittime) self.driver.find_element_by_xpath(password_xpath).send_keys(password) self.driver.implicitly_wait(waittime)
try: '''配置文件、登录用户名、密码''' cfgfile = os.path.abspath('.') + '/config.ini' url = excuteCFG.ConfigRead(cfgfile, 'setting', 'CPK_URL').CfgRead() username = excuteCFG.ConfigRead(cfgfile, 'setting', 'USERNAME').CfgRead() password = excuteCFG.ConfigRead(cfgfile, 'setting', 'PASSWORD').CfgRead() waittime = excuteCFG.ConfigRead(cfgfile, 'setting', 'WAITTIME').CfgRead() '''导航窗口,首页''' homepage = excuteCFG.ConfigRead(cfgfile, 'dashboard', 'homepage').CfgRead() '''平台架构切换''' platform_option = excuteCFG.ConfigRead(cfgfile, 'homepage', 'platform_option').CfgRead() platform = excuteCFG.ConfigRead(cfgfile, 'homepage', 'platform').CfgRead() except IOError, e: baseinfo.getErrorInfo() class HomePage(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() self.driver.maximize_window() self.driver.implicitly_wait(waittime) self.verificationErrors = [] self.accept_next_alert = True self.driver.get(url) self.driver.find_element_by_xpath( '//*[@id="content"]/div/div/div[2]/input[2]').send_keys(username) self.driver.implicitly_wait(waittime) self.driver.find_element_by_xpath( '//*[@id="content"]/div/div/div[3]/input[2]').send_keys(password)
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.common.exceptions import TimeoutException from base import baseinfo try: '''配置文件、登录用户名、密码''' cfgfile = os.path.abspath('.') + '/config.ini' url = excuteCFG.ConfigRead(cfgfile, 'setting', 'CPK_URL').CfgRead() username = excuteCFG.ConfigRead(cfgfile, 'setting', 'USERNAME').CfgRead() password = excuteCFG.ConfigRead(cfgfile, 'setting', 'PASSWORD').CfgRead() waittime = excuteCFG.ConfigRead(cfgfile, 'setting', 'WAITTIME').CfgRead() except IOError, e: # pass baseinfo.getErrorInfo('获取配置文件异常') class Login(unittest.TestCase): def setUp(self): print cfgfile print url print waittime print type(waittime) self.driver = webdriver.Firefox() self.driver.maximize_window() self.driver.implicitly_wait(waittime) self.verificationErrors = [] self.accept_next_alert = True def test_login(self):
legacy_security_items_xpath = excuteCFG.GetConfig().getAppManagement( 'legacy_security_items_xpath') legacy_applist_xpath = excuteCFG.GetConfig().getAppManagement( 'legacy_applist_xpath') legacy_app_pages_xpath = excuteCFG.GetConfig().getAppManagement( 'legacy_app_pages_xpath') legacy_appdetails_back_xpath = excuteCFG.GetConfig().getAppManagement( 'legacy_appdetails_back_xpath') legacy_app_sort_xpath = excuteCFG.GetConfig().getAppManagement( 'legacy_app_sort_xpath') except Exception as e: baseinfo.getErrorInfo('获取congfig.ini配置文件setting出错') print e class LegacyAppManagement(unittest.TestCase): def setUp(self): # self.driver = webdriver.Safari() self.driver = webdriver.Firefox() # self.driver = webdriver.Chrome() self.driver.maximize_window() self.driver.implicitly_wait(waittime) self.verificationErrors = [] self.accept_next_alert = True self.driver.get(url) self.driver.find_element_by_xpath(username_xpath).send_keys(username)