Type[Union[Firefox, Chrome, Ie, Edge]] = Chrome报错

来源:3-4 继承基类实现浏览器个性化

qq_Qian儭_03543846

2021-11-10

def init(self,
browser_type: Type[Union[Firefox, Chrome, Ie, Edge]] = Chrome,
option_type: Type[Union[FirefoxOptions, ChromeOptions, IeOptions]] = ChromeOptions,
driver_path: str = CHROME_DRIVER_PATH):

会报以下错误:
Traceback (most recent call last):
File “E:/pyworkspace/frameworkdemo/bo_demo/BrowseBase.py”, line 19, in
class BROWSER(object):
File “E:/pyworkspace/frameworkdemo/bo_demo/BrowseBase.py”, line 31, in BROWSER
driver_path: str = CHROME_DRIVER_PATH):
NameError: name ‘Type’ is not defined

写回答

1回答

qq_Qian儭_03543846

提问者

2021-11-11

这个问题已解决,没导入包导致,以为是版本问题

0
2
慕工程8594684
需要录入此行,导入包 from typing import Type,Union
2022-01-25
共2条回复

Python自动化测试开发实战,能帮你就业的测试课

开发高扩展、高可用的自动化测试框架,利用好测试自动化技术。

445 学习 · 157 问题

查看课程