python selenium 最简单示例
使用 pip 安装 selenium
下载 chromedriver,添加在PATH中
# -*- coding: utf-8 -*- from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
import time # Create a new instance of the browser driver
driver = webdriver.Chrome() ##可以替换为IE(), Firefox() Chrome() # go to the google home page
driver.get("https://www.google.com") # find the element that's name attribute is q (the google search box)
inputElement = driver.find_element_by_name("q") # type in the search
inputElement.send_keys("Cheese!") # submit the form. (although google automatically searches now without submitting)
inputElement.submit() # the page is ajaxy so the title is originally this:
print(driver.title) try:
# we have to wait for the page to refresh, the last thing that seems to be updated is the title
WebDriverWait(driver, 10).until(lambda driver : driver.title.lower().startswith("cheese!")) # You should see "cheese! - Google Search"
print(driver.title) finally:
driver.quit()
python selenium 最简单示例的更多相关文章
- python selenium 使用unittest 示例
python selenium 使用unittest 示例 并等待某个元素示例 from selenium.webdriver.support.ui import WebDriverWait from ...
- C#调用Python脚本的简单示例
C#调用Python脚本的简单示例 分类:Python (2311) (0) 举报 收藏 IronPython是一种在 .NET及 Mono上的 Python实现,由微软的 Jim Huguni ...
- Python+selenium之简单介绍unittest单元测试框架
Python+selenium之简单介绍unittest单元测试框架 一.unittest简单介绍 unittest支持测试自动化,共享测试用例中的初始化和关闭退出代码,在unittest中最小单元是 ...
- python+selenium之简单介绍继承
python+selenium之简单介绍继承 一.此例简单的介绍一下继承 1.面向对象的编程带来的主要好处之一是代码的重用,实现这种重用的方法之一是通过继承机制.继承完全可以理解成类之间的类型和子类型 ...
- 用map函数来完成Python并行任务的简单示例
众所周知,Python的并行处理能力很不理想.我认为如果不考虑线程和GIL的标准参数(它们大多是合法的),其原因不是因为技术不到位,而是我们的使用方法不恰当.大多数关于Python线程和多进程的教材虽 ...
- 【Python Selenium】简单数据生成脚本
最近因工作需要,写了一个简单的自动化脚本,纯属学习,顺便学习下selenium模块. 废话不多说,直接上代码!! 这里一位大神重写了元素定位.send_keys等方法,咱们直接进行调用. 适用Pyth ...
- python+selenium进行简单验证码获取
# _*_ coding:utf-8 _*_from PIL import Imagefrom selenium import webdriverimport pytesseractimport ti ...
- python信号signal简单示例
进程间通信之类的,用得着, 可以自定义接到信息之后的动作. file1.py #!/usr/bin/env python # -*- coding: utf-8 -*- import os impor ...
- Python + selenium + pycharm 环境部署细节 和selenium、Jenkins简单介绍
一.测试体系:Python + selenium + pycharm + Jenkins/docker 环境搭建: 1.安装python 3.4/3.5 2/3.6/ 3.7 2.配置环境变量 3.p ...
随机推荐
- 公钥密码RSA算法记录
介绍: RSA算法是1978年由 R.Rivest.A.Shamir.L.Adleman提出的一种用数论构造的.也是迄今为止理论上最为成熟.完善的公钥密码体,该体制已得到广泛的应用. 算法描述: 1. ...
- 【导航】FPGA相关
[博客索引] FPGA相关 数字电路实现上,较多的经验是基于Xilinx/Altera的FPGA,使用Verilog语言,实现光传输SDH.OTN通信协议,DDR3控制器应用,以及视频分割.合并.sc ...
- 开发环境---->服务器(数据库迁移Migration)
1.查找服务器环境迁移记录表的最近一次迁移名称 SELECT * FROM __efmigrationshistory; 最后一次:20190225075007_UpdateSocialApplyCo ...
- 好程序员技术分享html5和JavaScript的区别
好程序员技术分享html5和JavaScript的区别,HTML5广义上讲是前端开发学科的代名词,包含HTML5.CSS3及JavaScript三个重要的部分,是运行在浏览器上应用的统称.如PC端网站 ...
- Node.js如何执行cmd
最近正好因业务的一个需求需要研究如何根据vscode的插件名来下载对应的插件以解决之前将插件打包上传到服务器上面导致的延迟问题(插件体积小还好说,如果体积过大,即便是压缩打成zip包,如果同一时刻很多 ...
- (转)sizeof()和_countof()区别
先看程序: #include <iostream> using namespace std; int main(int argc, char* argv[]) { char *a = &q ...
- 记录nodejs的writeHead
使用response.writeHead()时,如果第二个参数的值使用错误的字符时,会使整个页面被镶嵌在<pre></pre>中被传输过去. 例: response.write ...
- VS2010动态链接库的生成及调用(C++)
一.动态链接库的生成 首先利用VS2010新建一个空的工程或者win32工程 2.在工程中添加头文件和源文件 3.工程属性配置 3.1 可以在解决方案目录下新建以下几个文件夹 bin (用于存放Rel ...
- 二、PHP基本语法 - PHP零基础快速入门
我们日常生活中,有些人使用普通话交流,有些人使用家乡话.类比到计算机的世界里,PHP 是人与计算机沟通的语言之一. 既然是语言,那就必须遵循一定的语法规则.譬如 A 向 B 表白,A 会对 B 说:& ...
- Spring缓存注解@Cacheable、@CacheEvict、@CachePut使用(转)
原文地址:https://www.cnblogs.com/fashflying/p/6908028.html 从3.1开始,Spring引入了对Cache的支持.其使用方法和原理都类似于Spring对 ...