1.YAMLLoadWarning: calling yaml.load() without Loader=… is deprecated, as the default Loader is unsafe
使用yaml 5.1版本因为安全问题报错
解决:加上yaml.load(input, Loader=yaml.FullLoader)
参考文件:https://www.jianshu.com/p/63e4c539bcfc
2.Python中self的用法详解,或者总是提示:TypeError: add() missing 1 required positional argument: 'self’的问题解决
解决:Common(dirver).check_login(dirver)
Common().check_login() ,一般出现这样的问题是没有实例化对象就开始引用或是引用的时候没有传递参数导致的
参考文件:https://blog.csdn.net/songlh1234/article/details/83587086
3.TypeError: ‘module’ object is not callable(“模块”对象不可调用)
解决:主要引入模块的名称是否正确,及其引用过程中函数调用方法是否正确
参考文件:https://blog.csdn.net/songlinjiang/article/details/82997926
4.python报错TypeError: ‘int’ object is not subscriptable
解决:以上报错的因为数组或字典没有引用不正确的下标导致
例如:y = self.driver.get_window_size()[‘height’]
y2 = int(y[1] * 0.2)
参考文件:https://www.cnblogs.com/JLZT1223/p/9376267.html
5. self.driver.find_elements(*self.lx)[2].click()
报错:IndexError: list index out of range
当该元素不存在时同样报该错误,并不是已经超出了下标范围
6.TypeError: Cannot create a consistent method resolution
order (MRO) for bases common_contest, Common
原因:由于继承混乱导致的问题,出现了重复继承
class contest(Common,common_contest)
class common_contest(Common)
解决:class contest(common_contest)
class common_contest(Common)
-
self.driver.find_element(element[num]).send_keys(data[element])
TypeError: unhashable type: ‘list’
原因:list 不使用 hash 值进行索引,故其对所存储元素没有可哈希的要求;set / dict 使用 hash 值进行索引,也即其要求欲存储的元素有可哈希的要求。Python不支持dict的key为list或dict类型,因为list和dict类型是unhashable(不可哈希)的。
元素定义:‘’xpath‘,‘’//[fefh]’’ 是一个list列表
参考文件:https://blog.csdn.net/lyq_12/article/details/81260427
解决:self.driver.find_element(*element[num]).send_keys(data[num]) -
self.get_screenshot_as_file(image_path)
报错:maximum recursion depth exceeded in comparison
原因:python默认的递归深度是很有限的(默认是1000),因此当递归深度超过999的样子,就会引发这样的一个异常。在获取当前文件路径时没有引用对应设备对象,不断重复执行了导致了溢出,
参考文件:https://www.cnblogs.com/clairedandan/p/10923108.html
解决:self.driver.get_screenshot_as_file(image_path)