Chrome浏览器与chromedriver.exe驱动可以是官网上最新的,

随意!

Chrome.py:

from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait options = webdriver.ChromeOptions()
options.add_argument("disable-infobars")
driver = webdriver.Chrome(chrome_options=options)
# 消除“Chrome正受到自动测试软件的控制”提示 driver.get("https://www.baidu.com")
# 打开百度首页
driver.maximize_window()
# 把浏览器窗口最大化
WebDriverWait(driver, 15).until(lambda x: x.find_element_by_xpath(".//*[@id='kw']"))
# 等待搜索框出现 driver.find_element_by_xpath(".//*[@id='kw']").send_keys("中国")
# 输入中国
driver.find_element_by_xpath(".//*[@id='su']").click()
# 点击搜索按钮
WebDriverWait(driver, 15).until(lambda x: x.find_element_by_xpath(".//*[@id='1']/h3/a"))
# 等待中国_百度百科元素加载 driver.close()
# 关闭浏览器窗口
driver.quit()
# 结束

Selenium(Python)驱动Chrome浏览器的更多相关文章

  1. Selenium+Python调Chrome浏览器时报Traceback (most recent call last): File "C:/Users/EDZ/Desktop/selenium_demo/demo001.py", line 12, in <module>

    上次使用Selenium+Python还是好几个月前了 今天想再用一下,结果写个打开网站的小demo报错,报错如下: 检查了一下,查看报错日志,应该是chrome版本和driver版本不一致导致的. ...

  2. selenium驱动chrome浏览器问题

    selenium是一个浏览器自动化测试框架,以下介绍其如何驱动chrome浏览器? 1.下载与本地chrome版本对应的chromedriver.exe ,下载地址为http://npm.taobao ...

  3. selenium webdriver启动Chrome浏览器后无法输入网址的解决办法

    通过selenium webdriver启动Chrome浏览器,脚本如下: from selenium import webdriver browser = webdriver.Chrome() br ...

  4. Selenium驱动Chrome浏览器

    import org.openqa.selenium.By;import org.openqa.selenium.WebDriver;import org.openqa.selenium.chrome ...

  5. 爬虫动态渲染页面爬取之selenium驱动chrome浏览器的使用

    Selenium是一个用于Web应用程序测试的工具.Selenium测试直接运行在浏览器中,就像真正的用户在操作一样,可以用其进行网页动态渲染页面的爬取. 支持的浏览器包括IE(7, 8, 9, 10 ...

  6. (原创)如何使用selenium 驱动chrome浏览器并且打开方式为手机模式-转载请注明出处

    随着移动设备使用率的不断增加,移动页面的测试也变得越来越重要. 对于互联网公司M站的测试,如果不通过专用的appium等移动端测试工具是否还有方便快捷的办法呢?答案当然是有啊. 使用chrome dr ...

  7. selenium python 启动Chrome

    启动Chrom浏览器 下载chromedriver: http://chromedriver.storage.googleapis.com/index.html 当时找chromedriver与chr ...

  8. selenium+python自动化87-Chrome浏览器静默模式启动(headless)

    前言 selenium+phantomjs可以打开无界面的浏览器,实现静默模式启动浏览器完成自动化测试,这个模式是极好的,不需要占用电脑的屏幕. 但是呢,phantomjs这个坑还是比较多的,并且遇到 ...

  9. python3.6中使用selenium + chromedriver访问Chrome浏览器时报错

    from selenium import webdriver from selenium.webdriver.chrome.options import Options if __name__ == ...

随机推荐

  1. ASP.NET Core 程序发布到Linux(Centos7)爬坑实战

    前言 前阶段弄了个Linux系统想倒腾倒腾.NET Core,结果看了下网上的资料,大部分都是过期的,走了不少弯路,不过还好,今下午总算捣鼓出来了.Linux命令太多了,唉.血的教训:安装一定要看官网 ...

  2. JavaScript:回调模式(Callback Pattern) (转载)

    JavaScript:回调模式(Callback Pattern) 函数就是对象,所以他们可以作为一个参数传递给其它函数: 当你将introduceBugs()作为一个参数传递给writeCode() ...

  3. vue2中用swiper

    一.安装swiper npm install --save swiper 二.home组件 //home.js <app-banner :listImg="bannerList&quo ...

  4. NSArray中地内存管理 理解

    问题: 通过alloc和init的方法创建了NSArray和NSDictionary,然后通过addobject和setobject:forkey:将object添加进去.通过addobject会自动 ...

  5. VS进行调试时IIS Express显示Access Define-坑爹的腾讯TGP助手

    今天在家使用VS进行调试的时候发现IIS Express死活启动不了,改用IIS也是不行,尝试了网上所说的所有办法,改了各种权限,找了各种注册表,最终未果,然后我想起之前被腾讯坑过的那次:http:/ ...

  6. 关于ucos操作系统中如何从邮箱中提取出消息

    问题提出? 定义两个任务,task1,task2,想task1用OSMboxPost,task2用OSMboxPend定义了一个邮箱Mbox1=OSMboxCreate(括号里面应该怎么写?)还有具体 ...

  7. javascript根据文件字节数返回文件大小

    function getFileSize(fileByte) { var fileSizeByte = fileByte; var fileSizeMsg = ""; if(fil ...

  8. string::size_type类型

    string::size_type类型 对于string中的size函数,size函数返回的是string对象的字符个数(长度),我们知道,对size()来说,返回一个int或者是一个unsigned ...

  9. The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.报该错误的一种原因。

    今天发现某个action返回404. HTTP Status 404 – Not Found Type Status Report Message /xxx.action Description Th ...

  10. Redis Sentinel 集群安装 step by step

    一. 准备材料 服务器 IP address 操作系统 位数 Redis 版本   CNT06CAH05 192.168.3.47 CentOS 6.5 x64 Redis-3.2.6 sentine ...