webdriver学习笔记(一):webdrive脚本打开firefox浏览器,报“AttributeError: module 'selenium.webdriver' has no attribu
按照网上提供的方法:
- 下载geckodriver之后解压缩到 Firefox安装目录 下
- 添加 Firefox安装目录 到 系统变量Path
- 重启pycharm
照此步骤执行后,仍然报同样的错。折腾了很久都没有成功。
后来求助群里的小伙伴,有人说添加外部库试试。于是在pycharm-setting-project Interpreter中手动添加了selenium。添加成功后,再重启pycharm,执行,成功!
最初用pip命令模式安装了selenium,系统提示安装成功,所以没想到这部分会出问题。以后还是得多思考,多试。
#encoding=utf-8
from selenium import webdriver
import time
#通过executable_path参数驱动文件所在路径
driver = webdriver.Firefox(executable_path = "C:\Program Files\Mozilla Firefox\geckodriver")
#driver = webdriver.Chrome(executable_path = "C:\Python27\Scripts\chromedriver.exe")
#driver = webdriver.Chrome()
#打开搜狗首页
driver.get("http://www.sogou.com")
#清空搜索框输入默认内容
driver.find_element_by_id("query").clear()
#在搜索框输入“光荣之路自动化测试”
driver.find_element_by_id("query").send_keys(u"光荣之路自动化测试")
#单击“搜索”按钮
driver.find_element_by_id("stb").click()
#等待3秒
time.sleep(3)
#退出浏览器
driver.quit()
webdriver学习笔记(一):webdrive脚本打开firefox浏览器,报“AttributeError: module 'selenium.webdriver' has no attribu的更多相关文章
- webdrive脚本打开firefox浏览器,报“AttributeError: module 'selenium.webdriver' has no attribu
按照网上提供的方法: 下载geckodriver之后解压缩到 Firefox安装目录 下 添加 Firefox安装目录 到 系统变量Path 重启pycharm 照此步骤执行后,仍然报同样的错.折腾了 ...
- AttributeError: module 'selenium.webdriver.common.service' has no attribute 'Service'
今天爬虫时需要使用到selenium, 使用pip install selenium进行安装. 可是一开始写程序就遇到了AttributeError: module 'selenium.webdriv ...
- 树莓派3B+学习笔记:12、安装FireFox浏览器
1.在终端中输入 sudo apt-get install iceweasel 2.安装完成后菜单中会自动生成快捷方式 什么是 iceweasel? Iceweasel 是 Firefox(火狐浏览器 ...
- pycharm最新版新建工程没导入本地包问题:module 'selenium.webdriver' has no attribute 'Firefox'
前言 最新版的pycharm做了很大的改变,新建工程的时候,默认不导入本地的安装包,这就导致很多小伙伴踩坑了... 明明已经pip安装过selenium了,但是却报AttributeError:mod ...
- Python3+Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )
!/usr/bin/env python -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )'''from selenium im ...
- Python3+Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)'''from sel ...
- Python3+Selenium3+webdriver学习笔记12(js操作应用:滚动条 日历 内嵌div)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记12(js操作应用:滚动条 日历 内嵌div)'''from ...
- Python3+Selenium3+webdriver学习笔记11(cookie处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记11(cookie处理)'''from selenium im ...
- Python3+Selenium3+webdriver学习笔记10(元素属性、页面源码)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记10(元素属性.页面源码)'''from selenium i ...
随机推荐
- nginx_uWSGI_django_virtualenv_supervisor发布web服务器
nginx_uWSGI_django_virtualenv_supervisor发布web服务器 nginx 导论 123456789101112131415161718192021222324252 ...
- Qt事件系统之三:键盘事件
QKeyEvent类用来描述一个键盘事件.当键盘按键被按下或者被释放时,键盘事件便会被发送给拥有键盘输人焦点的部件. QKeyEvent的key()函数可以获取具体的按键,对于Qt中给定的所有按键,可 ...
- 员工管理系统(集合与IO流的结合使用 beta4.0 ObjectInputStream/ ObjectOutputStream)
package cn.employee_io; import java.io.Serializable; public class Employee implements Serializable{ ...
- asp.net网站接入QQ登录
这两天在做网站第三方登录,总结一下QQ登录吧,支付宝就不用了(下载dome把ID什么的换一换就基本可以了.),本文主要说的是代码的实现方式,逻辑部分主要还是根据帮助文档来的.不懂的同学可以先看看文档. ...
- 掌握Spark机器学习库-05-spark中矩阵与向量的使用
1)介绍 矩阵: Matrix,看做二维表,基本运算(+,-,*,T) 向量: Vectors,方向和大小,基本运算,范数 2)spark中向量的使用(主要使用breeze.linalg) 3)spa ...
- leetcode:single-number-ii(Java位运算)
题目 Given an array of integers, every element appears three times except for one. Find that single on ...
- iOS之NSAttributedString-------字符属性
NSAttributedString 字符属性 字符属性可以应用于 attributed string 的文本中. NSString *const NSFontAttributeName;(字体) N ...
- greenplum4.3.8.2安装
GREENPLUM总体结构: 数据库由Master Severs和Segment Severs通过Interconnect互联组成. Master主机负责:建立与客户端的连接和管理:SQL的解析并 ...
- getDate() 各种时间格式
Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AMSelect CONVERT(varchar(100), GETDATE() ...
- 观锁和乐观锁——《POJOs in Action》
1 事务隔离 事务隔离是数据库提供的功能. SQL Server通过SET TRANSACTION ISOLATION LEVEL语句设置事务隔离级别: SET TRANSACTION ...