from .filename import class

本质上来讲:如果用 某文件from  . 导入即相对引用,不能直接python 该文件 ,只能 间接被使用;因为该文件的__name__属性不能作为__main__;

至于为什么不能作为__main__就不清楚了;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
import os import time import platform from selenium import webdriver as webdriver1 from selenium.webdriver.ie.options import Options from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from config import global_wait,root_url,use_edge,iedriver_path,edgedriver_path,chromedriver_path from public.basiclogger import LOGGING class BaseCase(object): '''基础用例''' def get_web_driver(self,url,data=None,browser='ie'): if browser=='chrome': #if platform.system()=="Windows": # os.system(r'taskkill /f /im chrome.exe') #else: # os.system(r"ps aux |grep chrome|awk '{print $2}'|xargs -i kill {}") options = webdriver1.ChromeOptions() options.add_experimental_option('excludeSwitches', ['enable-logging']) self.driver = webdriver1.Chrome(executable_path=chromedriver_path,options=options) self.driver.get(url) self.driver.maximize_window() self.driver.implicitly_wait(global_wait) else: #启动IE之前先杀死电脑上所有的IE if use_edge: os.system(r'taskkill /f /im msedge.exe') else: os.system(r'taskkill /f /im iexplore.exe') if use_edge: file1=edgedriver_path else: file1=iedriver_path options = Options() options.ignore_protected_mode_settings = True options.ignore_zoom_level = True if use_edge: options.attach_to_edge_chrome = True options.edge_executable_path = r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" else: options.add_argument('--user-agent="Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko"') self.driver=webdriver1.Ie(executable_path=file1,options=options) self.driver.get(url) self.driver.maximize_window() self.driver.implicitly_wait(global_wait) def get_logger(self): #创建日志文件名 filename=self.data["case_name"]+'_'+time.strftime("%Y-%m-%d_%H-%M-%S") #保存连接 filename1=os.path.join(r'test_log',filename+r'.log') LOGGING1=LOGGING(log_name=filename,log_dir="test_log") self.logger=LOGGING1.logObject self.LOGGER=LOGGING1
05-30

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值