代码:

#coding = utf-8
from selenium import webdriver
import time
##############5-6:实现多窗口切换_start##############
driver = webdriver.Chrome()
driver.get('https://www.imooc.com/user/newlogin')
driver.find_element_by_name('email').send_keys('gj10010@163.com')
driver.find_element_by_name('password').send_keys('20200319gj')
driver.find_elements_by_class_name('moco-btn').click()
driver.get('https://www.imooc.com/user/setbindsns')
driver.find_elements_by_class_name('inner-i-box').find_elements_by_class_name('moco-btn-normal').click()
time.sleep(2)
current_handl = driver.current_window_handle
handl_list = driver.window_handles
print(handl_list)
for i in handl_list:
    if i != current_handl:
        time.sleep(2)
        driver.switch_to_window(i)
        driver.find_element_by_name('username').send_keys('13501913831')
        driver.find_element_by_name('password').send_keys('1351913831gj')
driver.close()
##############5-6:实现多窗口切换_end################
 
结果:
DevTools listening on ws://127.0.0.1:57048/devtools/browser/2f83b3cd-583f-4513-bccd-42c34432e0d4
Traceback (most recent call last):
  File "e:/30.Study/30.自动化测试/99.零基础入门 Python Web 自动化测试/10.seleniumCodePractice/202006/open_window_5-6.py", line 10, in <module>
    driver.find_elements_by_class_name('moco-btn').click()
AttributeError: 'list' object has no attribute 'click'
PS E:\30.Study\30.自动化测试\99.零基础入门 Python Web 自动化测试\10.seleniumCodePractice\202006>
 

原因分析:

 
对策:
driver.find_elements_by_class_name('moco-btn').click()
==>
driver.find_elements_by_class_name('moco-btn')[0].click()
 
 
 
 
 
 
 

5-6:实现多窗口之异常(AttributeError: 'list' object has no attribute 'click')的更多相关文章

  1. py+selenium 明明定位不到元素,但却不报错或是报错AttributeError: 'list' object has no attribute 'click'【已解决】

    问题:定位不到元素,但却不报错或者出现报错AttributeError: 'list' object has no attribute 'click' 如图  或者  解决方法:   将”driver ...

  2. Django 运行报异常:AttributeError: 'str' object has no attribute 'get'

    Technorati Tags: Python,Django,Web 在使用django.contrib.auth用户机制进行用户的验证.登录.注销操作时,遇到这个异常. 首先是写了一个登录的视图,要 ...

  3. PyQt: “AttributeError: 'Form' object has no attribute 'exec_'” when opening second window

    # -*- coding: utf-8 -*- import sys from PyQt5.QtWidgets import QApplication , QMainWindow from PyQt5 ...

  4. PyQt程序执行时报错:AttributeError: 'winTest' object has no attribute 'setCentralWidget'的解决方法

    用QtDesigner设计了一个UI界面,保存在文件Ui_wintest.ui中,界面中使用了MainWindow窗口,窗口名字也叫MainWindow,用PyUIC将其转换成了 Ui_wintest ...

  5. Django项目启动 AttributeError: ‘str‘ object has no attribute ‘decode‘ 问题

    Watching for file changes with StatReloader Performing system checks... System check identified no i ...

  6. Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法

    最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...

  7. AttributeError: 'list' object has no attribute 'write_pdf'

    我在可视化决策树,运行以下代码时报错:AttributeError: 'list' object has no attribute 'write_pdf' 我使用的是python3.4 from sk ...

  8. attributeError:'module' object has no attribute ** 解决办法

    写了一个小脚本,执行的时候报错: Traceback (most recent call last): File "F:/test/qrcode.py", line 109, in ...

  9. AttributeError: 'module' object has no attribute 'TornadoAsyncNotifier'

    /*************************************************************************** * AttributeError: 'modu ...

  10. AttributeError: 'dict_values' object has no attribute 'translate'

    /***************************************************************************************** * Attribu ...

随机推荐

  1. Day 23 23.1:js加密算法

    js加密算法 逆向重点掌握的内容: 1.逆向的思维 2.网站逆向的分析思路和步骤 注意:重点不是放在代码中,而是分析的思路和套路(技巧) 逆向到底是什么? 通俗来讲,逆向就是处理爬虫过程中对于加密数据 ...

  2. ASP.NET Core 部署在Docker容器当中(1)

    一.前言 在公司新项目中,果断选择使用asp.net core,通过实践学习一系列技术栈:docker.docker-nginx.docker-compose.Jenkins,本文主要是介绍如何将项目 ...

  3. abap链接My sql

    Linux中ODBC源的建立--MySQL 需要用到数据库,但我用的是Linux,只能在下面安装ODBC和MYSQL     1.安装必要的包         安装ODBC     sudo apt- ...

  4. Python: 取消numpy科学计数法

    Numpy中默认是使用科学计数法来显示数据的,但是这种做法往往不利于我们观测数据,比如坐标数据等.那么如何取消numpy科学计数法呢,请往下看. np.set_printoptions() impor ...

  5. [Maven] 引入依赖以后如果标红怎么办

  6. CSS:盒子_每个元素都有两个盒子(《CSS世界》笔记-块级元素)

    CSS:盒子_每个元素都有两个盒子(<CSS世界笔记>-块级元素) 1)CSS世界只有"块级盒子(block-level box)"和"内联盒子(inline ...

  7. [CSS]隐藏浏览器滚动条

    ::-webkit-scrollbar {   display: none; /* Chrome Safari */ }

  8. MongoDB升级

    因业务需要所以需要对mongoDB客户端jar包升级,在此记录一些过程 1.jar包替换,引入依赖 3.2.2: mongo-java-driver     |     4.6.1: mongo-dr ...

  9. C# 将Dll文件打包到exe中

    首先在资源管理里面将需要使用的dll添加进入 然后将dll文件的生成操作改成嵌入的资源 然后新建一个类  LoadResourceDll.cs 1 using System; 2 using Syst ...

  10. python菜鸟学习: 13. excel文件编辑openpyxl使用

    #1. xls文件转换成xlsx文件,需要使用到 win32com from win32com import client as wc filepath = "D:\\python\\liy ...