1、yaml文件写的是:
platformVersion: 10
2、driver初始化:
data = yaml.load(file, Loader=yaml.FullLoader)
desired_caps = {}
desired_caps['platformVersion'] = data['platformVersion']
3、运行后报错:selenium.common.exceptions.SessionNotCreatedException: Message: A new session could not be created. Details: The desiredCapabilities object was not valid for the following reason(s): 'platformVersion' must be of type string
4、报错原因是因为platformVersion的value是“10”,经data调用后不是字符串类型了,所以会报错'platformVersion' must be of type string,加个str转换一下就好了:
desired_caps['platformVersion'] = str(data['platformVersion'])
5、重新运行,错误消失
1640

被折叠的 条评论
为什么被折叠?



