assert "login" in browser.title

browser.implicitly_wait(10)

elem = browser.find_element_by_id("txtAccount") # Find the query box elem.send_keys("0@cm.com")

log=browser.find_element_by_id("txtPwd2") log.send_keys("123456" + Keys.RETURN)

#be carefully the big-small time.sleep(2)# Let the page load, will be added to the API #

browser.find_elements_by_xpath("//ul[@id='menu']/li[2]/a").click() print"contract to be assigned"

browser.implicitly_wait(10) browser.find_elements_by_xpath("//body/div[2]/div/div/div[2]/table/tbody/tr/td/a").click()

报错信息:

Traceback (most recent call last):
  File "E:\eclipse\PythonCase\src\Python27\btn_test.py", line 20, in <module>
    browser.find_elements_by_xpath("//body/div[2]/div/div/div[2]/table/tbody/tr/td/a").click()    
AttributeError: 'list' object has no attribute 'click'

解决办法:

browser.find_elements_by_xpath("//body/div[2]/div/div/div[2]/table/tbody/tr/td/a") 这个方法返回一个list webelement 的集合

要想返回单个webelement 得用browser.find_element_by_xpath,这个要特别注意对于初学者加S和不加S的区别

python +selenium识别不来click事件,出现报错的更多相关文章

  1. 【Python + Selenium】初次用IE浏览器之报错:selenium.common.exceptions.WebDriverException: Message: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones.

    初次用IE浏览器运行自动化程序时,报错:selenium.common.exceptions.WebDriverException: Message: Unexpected error launchi ...

  2. easyui treegrid idField 所在属性中值有花括号(如Guid)当有鼠标事件时会报错,行记录一下

    easyui treegrid idField 所在属性中值有花括号(如Guid)当有鼠标事件时会报错,行记录一下

  3. Selenium click不生效 报错selenium.common.exceptions.InvalidArgumentException

    记录在使用selenium过程中踩的坑------ 在使用selenium时,用click点击网站弹出的文件上传框的"上传文件"按钮不生效,报错selenium.common.ex ...

  4. 解决python 导入selenium 库后自动化运行成功但是报错问题

    本章节开始进入自动化的基础教学了,首先我们要对我们的工具有一定的熟练使用程度,做自动化常用的工具一个是搭建 RobotFramework自动化框架,另外一个便是我们最常用的python 工作原理是比较 ...

  5. 【Selenium】【BugList4】执行pip报错:Fatal error in launcher: Unable to create process using '""D:\Program Files\Python36\python.exe"" "D:\Program Files\Python36\Scripts\pip.exe" '

    环境信息: python版本:V3.6.4 安装路径:D:\Program Files\python36 环境变量PATH:D:\Program Files\Python36;D:\Program F ...

  6. Python HTMLTestRunner生成网页自动化测试报告时中文编码报错UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6

    1. 由于使用Python Selenium做网页自动化测试时,有截取网页上的中文信息保存到测试结果中,最终出现编码错误如下: File "D:/PycharmProjects/AutoTe ...

  7. 【Python】【BugList12】python自带IDLE执行print(req.text)报错:UnicodeEncodeError: 'UCS-2' codec can't encode characters in position 93204-93204

    [代码] # -*- coding:UTF-8 -*- import requests if __name__ == '__main__': target = 'https://unsplash.co ...

  8. python创建__init.py__文件导入模块仍然报错ModuleNotFoundError: No module named 'name'

    今自定义模块后非相同目录导出提示找不到模块报错信息如下: ModuleNotFoundError: No module named 'name' 各方查找各位大神方法很多 参考链接 1.在需要导入的文 ...

  9. python学习笔记之——python安装mysqldb后,pycharm导入还是报错问题

    在安装mysqldb过程中遇到,本来已经安装了mysqldb了,但是在pycharm中import   MySQLdb还是报错找不到该模块的问题.解决方法如下:1.file->settings ...

随机推荐

  1. 关于<软件>的定义

    百度百科: 软件是一系列按照特定顺序组织的计算机数据和指令的集合.一般来讲软件被划分为系统软件.应用软件和介于这两者之间的中间件. 国标中的定义: 与计算机系统操作有关的计算机程序.规程.规则,以及可 ...

  2. Tomcat映射路径

    打开tomcat安装包,在config目录下修改server.xml文件: 在<Host>标签中添加: <Context path="" docBase=&quo ...

  3. Desert King POJ - 2728(最优比率生产树/(二分+生成树))

    David the Great has just become the king of a desert country. To win the respect of his people, he d ...

  4. TCP/IP详解 卷一学习笔记(转载)

    https://blog.csdn.net/cpcpcp123/article/details/51259498

  5. 利用kibana插件对Elasticsearch查询

    利用kibana插件对Elasticsearch查询 Elasticsearch是功能非常强大的搜索引擎,使用它的目的就是为了快速的查询到需要的数据. 查询分类: 基本查询:使用Elasticsear ...

  6. Ubuntu下编译SqlCipher以及解密微信数据库EnMicroMsg.db过程和坑

    wget https://codeload.github.com/sqlcipher/sqlcipher/zip/v3.4.2 ./configure --enable-tempstore=yes C ...

  7. html5 input输入实时检测以及延时优化

    有个项目是,这么个情况,输入框,实时监测输入,触发请求. 第一想法是input 上的onchange()方法,试了一下,不好用,是值等更改确认了,才会触发,不即时. 上网查了一下, $("# ...

  8. 彻底卸载Windows Service

    前言,我使用Quartz.net + quartz.config + quartz_jobs.xml 写了个Windows Service,使用如下bat脚本执行服务的安装,启动,暂停,卸载 @ech ...

  9. Git 实用指南

    传送门: https://mp.weixin.qq.com/s?__biz=MzI3MzgxNDY2MQ==&mid=2247484159&idx=1&sn=2d28513ef ...

  10. H5测试点总结-UI测试、功能测试、兼容性测试、体验相关(弱网、资源、手机操作等)、安全性测试、性能测试

    一.概述 1.1 什么是H5 H5 即 HTML5,是最新的 Web 端开发语言版本,现如今,大多数手机 APP 页面会用 H5 实现,包括 PC Web 站点也会用它开发实现.所以 Web 的通用测 ...