selenium+python unittest实践过程之问题杂集

1.列表选择项后直接获取文本内容获取不到,应该获取选择后显示的button的值

2.取值后的值带有空格,可以使用.strip()删除前后空格,以便断言

3.取值后有些值需要对类型进行转换才能断言成功

4.对于checkbox以及分页的遍历遇到的问题

每次勾选checkbox点击查询或者是点击页数按钮,页面都会刷新,webelement获取的元素过期,for循环的遍历失败

报错:

Error:
selenium.common.exceptions.StaleElementReferenceException: Message: The element reference of <input> stale: either the element is no longer attached to the DOM or the page has been refreshed

目前没有找到解决的方法,亟待大神帮忙

5.使用sublime软件写代码,运行脚本后发现经常出现这个错误:

unindent does not match any outer indentation level

找了半天的错误最后才发现是空格缩进的问题:

所以查看>缩进>使用空格缩进,这样就可以搞定了

后期会继续记录遇到的问题......

posted @ 2017-08-20 17:14  鱼的记忆只有七秒  阅读(434)  评论(0编辑  收藏  举报