摘要: Keys()类提供了键盘上几乎所有按键的方法。 send_keys()方法可以用来模拟键盘输入,除此之外, 我们还可以用它来输入键盘上的按键, 甚至是组合键, 如 Ctrl+A、 Ctrl+C 等。 from selenium import webdriver # 引入 Keys 模块 from s 阅读全文
posted @ 2019-11-18 11:40 左_右 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 在 WebDriver 中, 将这些关于鼠标操作的方法封装在 ActionChains 类提供。 ActionChains 类提供了鼠标操作的常用方法: perform(): 提交 context_click(): 点击 double_click(): 双击 drag_and_drop(): 拖动 阅读全文
posted @ 2019-11-18 11:30 左_右 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 设置浏览器窗口大小 from selenium import webdriver driver = webdriver.Chrome() driver.set_window_size(400, 500) #宽400 ,高500显示 driver.maximize_window() #全屏显示 控制浏 阅读全文
posted @ 2019-11-15 16:38 左_右 阅读(135) 评论(0) 推荐(0) 编辑
摘要: selenium定位方法 Selenium提供了8种定位方式。 id name class name tag name link text partial link text xpath css selector #写法如下: find_element_by_id() #id定位 find_elem 阅读全文
posted @ 2019-11-15 16:07 左_右 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 下载浏览器驱动 当selenium升级到3.0之后,对不同的浏览器驱动进行了规范。如果想使用selenium驱动不同的浏览器,必须单独下载并设置不同的浏览器驱动。 各浏览器下载地址: Firefox浏览器驱动:geckodriver Chrome浏览器驱动:chromedriver IE浏览器驱动: 阅读全文
posted @ 2019-11-15 15:41 左_右 阅读(455) 评论(0) 推荐(0) 编辑
摘要: python环境 请看这里: https://www.cnblogs.com/zuoyou1223/p/11847541.html 编辑器: pycharm 下载地址: https://www.jetbrains.com/pycharm/download/#section=windows pycha 阅读全文
posted @ 2019-11-15 15:27 左_右 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 异常 即便Python程序的语法是正确的,在运行它的时候,也有可能发生错误。运行期检测到的错误被称为异常。 大多数的异常都不会被程序处理,都以错误信息的形式展现在这里: 10 * (1/0) Traceback (most recent call last): File "<stdin>", lin 阅读全文
posted @ 2019-11-14 14:44 左_右 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 读 text 文件 f = open('read.txt','r') #指定文件,r=read print(f.read()) with open('read.txt','r') as f: a = f.read() print(a) 逐行读取 data = [] #创建空列表 for line i 阅读全文
posted @ 2019-11-13 16:24 左_右 阅读(77) 评论(0) 推荐(0) 编辑
摘要: if / if...else / if...elif...else 语句 1 a = 1 2 b = 2 3 if a < b: 4 print('a < b') 5 if a > b: 6 print('a > b') 1 a = 1 2 b = 2 3 if a < b: 4 print('a 阅读全文
posted @ 2019-11-13 15:08 左_右 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 编码格式: # -*- coding: UTF-8 -*- 写在第一行,py3默认编码格式是utf-8,你也可以指定其他格式 注释 单行注释: # 多行注释: ''' ''' 编写格式 python中用 Tab键缩进 导入 导入模块: import time 导入方法: from time impo 阅读全文
posted @ 2019-11-13 11:45 左_右 阅读(87) 评论(0) 推荐(0) 编辑