def open(self): """打开浏览器,写入cookies登录信息""" yamldict = getYamlfield(gl.configFile) ck_dict = yamldict['CONFIG']['Cookies']['LoginCookies'] self._open(self.base_url, self.pagetitle) self.addCookies(ck_dict) self._open(self.base_url, self.pagetitle)
def getCode(self, data): """ 从Boss获取验证码 :param data: 参数化数据 :return: 验证码 """ """参数变量url,cookies,time""" yamldict = getYamlfield(gl.configFile) cookies = yamldict['CONFIG']['Cookies']['BossLoginCookies'] #timeStr = time.strftime('%Y-%m-%d') url = 'http://boss.beta.acewill.net/sms/search?phone={0}&begin={1}&end={2}'.format( data['PhoneNo'], gl.curDate, gl.curDate) """设置浏览器,选项,隐藏获窗口运行""" option = webdriver.ChromeOptions() option.add_argument('disable-infobars') #不显示"Chrome正在受自动测试软件控制" option.add_argument('headless') #后台运行,不显示界面 """启动浏览器,增加cookies""" driver1 = webdriver.Chrome(chrome_options=option) driver1.maximize_window() driver1.get(url) driver1.implicitly_wait(30) driver1.add_cookie(cookies) driver1.get(url) """获取验证码,并返回验证码""" txtcode = driver1.find_element_by_xpath( self.consume.boss_code_xpath).text code = json.loads(txtcode)['template']['yanzhengma'] driver1.quit() return code
def __init__(self): self.curDateTime = str(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())) #当前日期时间 self.config = scripts.getYamlfield(gl.configFile) #配置文件路径 self.sender = self.config['EMAIL']['Smtp_Sender'] # 从配置文件获取,发件人 self.receivers = self.config['EMAIL']['Receivers'] # 从配置文件获取,接收人 self.msg_title = self.config['EMAIL']['Msg_Title'] #从配置文件获取,邮件标题 self.sender_server = self.config['EMAIL']['Smtp_Server'] #从配置文件获取,发送服务器 self.From = self.config['EMAIL']['From'] self.To = self.config['EMAIL']['To']
def open(self): """打开浏览器,写入cookies登录信息""" yamldict = getYamlfield(gl.configFile) ck_dict = yamldict['CONFIG']['Cookies']['LoginCookies'] self._open(self.base_url) self.add_cookies(ck_dict) self._open(self.base_url) if self.driver.title != self.pagetitle: self.getImage() assert self.driver.title == self.pagetitle, "断言标题错误,请查检页面"