selenium--unittest字符串/整型问题Can't convert 'int' object to str implicitly提示解决方法
来源:互联网 发布:mysql exists 原理 编辑:程序博客网 时间:2024/06/07 05:51
我们在用到selenium做自动化测试的时候,经常会碰到输入int类型的常量或变量,但是
python里默认的只认字符串类型的数据,所以在运行脚本的时候经常会出现Can't convert
'int' object to str implicitly的报错,那我们一般这样解决就行了。
一、我们来看一个例子
这里x输出的是个整型的数据,然后我们直接调用这个整型数据:
二、我们来运行一下这个脚本
运行后报错了:Can't convert 'int' object to str implicitly,并且报错的语句就是直接调用
X的那条语句:
这里报错的意思就是这个语句里面含有对象为整型的数据,不能直接赋予字符串类型。
那么我们来改一下语句,在调用x之前给他赋予字符串类型:
三、我们改了语句后再次运行看一下
运行后没有问题了,脚本正常运行并且正确输出结果:
Python默认只认字符串类型的常量或变量,大家在调用这些数据之前一定记得要转成
字符串类型,不然就会报错,特别是脚本比较多的时候一定得注意,不然定位起问题来
都比较困难。如果有问题可以交流QQ群:610845268
0 0
- selenium--unittest字符串/整型问题Can't convert 'int' object to str implicitly提示解决方法
- python:字符串和数字拼接 (TypeError: Can't convert 'int' object to str implicitly)
- str convert to int
- Can't convert to dimension: type=0x12问题
- 异常:Can't convert argument: null解决方法
- ruby操作mysql数据库报错提示can't convert Fixnum into String解决方法
- svn: Can't convert string from 'UTF-8' to native encoding 解决方法
- Cannot implicitly convert type 'System.Collections.ArrayList' to 'object[]' ;System.Security.SecurityException: Requested regist
- c++ int to string 整型到字符串
- c++ int to string 整型到字符串
- java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12问题
- java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12问题
- 解决svn: Can't convert string from 'UTF-8' to native encoding问题
- 解决svn: Can't convert string from 'UTF-8' to native encoding问题
- 解决svn: Can't convert string from 'UTF-8' to native encoding问题
- Selenium Firefox Python错误can't access dead object?
- 在linux中svn下载文件时提示svn: Can't convert string from 'UTF-8' to native encoding:
- Convert int? to int
- TextView中文字的跑马灯效果实现,以及focusable,focusableInTouchMode属性介绍
- RSA密码系统
- qt 之 加密算法
- mysql 5.7 增加用户并授权
- wemall商城 7.0 开源系统发布,支持公众号和小程序开发
- selenium--unittest字符串/整型问题Can't convert 'int' object to str implicitly提示解决方法
- 简单拍照
- python 爬虫之路教程
- myeclipse加载tomcat包
- 线程池的原理和连接池的原理
- 有关iOS命名规范
- 剑指Offer——(7)斐波那契数列
- springboot使用Freemarker继承
- android View coordinate(坐标)