def __init__(self, driver): self.register_handle = RegisterHandle(driver) self.driver = driver self.ini = ReadIni() self.txt = WriteTxt() self.register = RegisterBusiness(self.driver) self.register_page = RegisterPage(driver) self.fill_data_handle = FillDataHandle(driver) self.driver.implicitly_wait(20)
def get_local_config(self, local_config): """ 读取配置文件 :param local_config: 配置文件的key :return: 返回值的list """ read_ini = ReadIni() ini = read_ini.get_value_tuple(local_config) return ini
def get_element(self, file_path, section, key): read_ini = ReadIni(file_path) local = read_ini.get_value(section, key) by = local.split('>')[0] local_by = local.split('>')[1] if by == 'id': return self.driver.find_element_by_id(local_by) elif by == 'className': return self.driver.find_element_by_class_name(local_by) else: return self.driver.find_element_by_xpath(local_by)
def __init__(self,driver): self.login_handle = LoginHandle(driver) self.driver = driver self.ini = ReadIni() self.txt = WriteTxt() self.login_page = LoginPage(driver) self.username = self.ini.get_value('username','login_value') self.password = self.ini.get_value('password','login_value') self.error_username = self.ini.get_value('error_username', 'login_value') self.error_pwd = self.ini.get_value('error_pwd', 'login_value') self.mt4 = self.ini.get_value('mt4id','login_value') self.error_mt4 = self.ini.get_value('error_mt4id','login_value') self.driver.implicitly_wait(15)
def get_element(self, key): read_ini = ReadIni() data = read_ini.get_value(key) by = data.split('>')[0] value = data.split('>')[1] try: if by == 'id': return self.driver.find_element_by_id(value) elif by == 'name': return self.driver.find_element_by_name(value) elif by == 'className': return self.driver.find_element_by_class_name(value) else: return self.driver.find_element_by_xpath(value) except: self.driver.save_screenshot( 'F:\Pycharm\muke\POpractice\image\%s.png' % value) return None
def __init__(self, driver): self.register_handle = RegisterHandle(driver) self.driver = driver self.ini = ReadIni() self.txt = WriteTxt() self.register_page = RegisterPage(driver) self.login_handle = LoginHandle(driver) self.phone = self.ini.get_value('phone', 'register_input_value') self.verification_code = self.ini.get_value('Verification_Code', 'register_input_value') self.mail = self.ini.get_value('mail', 'register_input_value') self.call = self.ini.get_value('call', 'register_input_value') self.pwd = self.ini.get_value('pwd', 'register_input_value') self.confirm_pwd = self.ini.get_value('confirm_pwd', 'register_input_value') self.introducer = self.ini.get_value('introducer', 'register_input_value') self.driver.implicitly_wait(20)
def android_driver(self, i): ini = ReadIni( node="server_port", file_name= r"D:\测试\自动化测试\App自动化测试\appium--慕课网登录模块\config\userconfig.ini") deviceName = ini.get_value("devices" + str(i)) port = ini.get_value("appium_port" + str(i)) capabilities = { "platformName": "Android", # "automationName": "UiAutomator2", "deviceName": deviceName, "app": "D:\\测试\\APPnium\\mukewang.apk", "noReset": "true" } driver = webdriver.Remote("127.0.0.1:" + port + "/wd/hub", capabilities) time.sleep(5) return driver
def __init__(self, pass_list, fail_list,error_list): self.pass_list = pass_list self.fail_list = fail_list self.error_list = error_list self.reportname = self.new_report() self.read_ini = ReadIni()
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @Time : 2019/9/9 22:37 # @Author : Mandy import conftest from utils.read_ini import ReadIni read = ReadIni(conftest.env_dir) class CommonUrl: def __init__(self): self.user_register_url = self.join_url('/user/register') self.user_register_url = self.join_url('/user/register') self.user_info_url = self.join_url('/user/info') self.user_edit_info_url = self.join_url('/user/editInfo') self.user_edit_gender_url = self.join_url('/user/editFavGender') self.user_basic_info_url = self.join_url('/user/basic') def join_url(self, test_url): base_url = read.get_value('base_url', 'api') url = base_url + test_url return url common = CommonUrl() print(common.user_register_url)
#coding:utf-8 from selenium import webdriver from utils.read_ini import ReadIni from base.find_element import FindElement read_ini = ReadIni("User") user = read_ini.get_value("user") pwd = read_ini.get_value("pwd") class LoginFunction(object): def __init__(self,url): self.driver = self.get_driver(url) def get_driver(self,url): driver = webdriver.Chrome() driver.get(url) driver.maximize_window() return driver #输入用户信息 def send_user_info(self,element,data): element.send_keys(data) #定位用户信息 def get_user_element(self,key): find_element = FindElement(self.driver) user_element = find_element.get_element(key) return user_element def main(self): eles = self.get_user_element('user_name')
def __init__(self): self.excel = OperationExcel() self.data_config = global_var() self.read = ReadIni(conftest.env_dir) self.op_json = OperationJson()
def __init__(self): self.dos = DosCmd() self.ini = ReadIni( file_name= r"D:\测试\自动化测试\App自动化测试\appium--慕课网登录模块\config\userconfig.ini")
def get_local_config(self, local_config, node=None, file_name=None): read_ini = ReadIni(node=node, file_name=file_name) info = read_ini.get_value_tuple(local_config) return info