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. MVC学习九:MVC 特性本质

    一.特性的本质就是:对属性.方法.类加特性,本质就是new 一个特性类对象赋值给属性.方法.类. 可以通过反射的方式取得特性的值,代码如下: ①自定义特性 public class MyAttribu ...

  2. 图片左右滚动控件(带倒影)——重写Gallery

    转http://blog.csdn.net/ryantang03/article/details/8053643 今天在网上找了些资料,做了一个图片左右滚动的Demo,类似幻灯片播放,同时,图片带倒影 ...

  3. win8安装wampserver报403错误解决方法

    看着别人开始体验win8了,前几天我也安装了win8系统,总体来说还不错,但是今天安装完Wampserver后,浏览器输入localhost,竟然报了403错误,我以为我安装出错了,后来研究了半天,发 ...

  4. WINDOWS 负载均衡NLB配置中单播与多播区别(转载)

    单播 在单播模式下,NLB重新对每个NLB节点中启用NLB的网络适配器分配MAC地址(此MAC地址称为群集MAC地址),并且所有的NLB节点均使用相同的MAC地址(均使用群集MAC地址),同时NLB修 ...

  5. ios下引用MUI后input不能输入,Android端正常

    原因是mui框架的有个css样式 *{ -webkit-user-select: none; } 其作用是禁掉用户可以选中页面中的内容. 添加以下style样式即可 input{ -webkit-us ...

  6. 『ACM C++』 PTA 天梯赛练习集L1 | 052-053

    今日刷题,水题水题 ------------------------------------------------L1-052------------------------------------ ...

  7. chromium之histogram.h

    histogram不知道是干啥的 // Histogram is an object that aggregates statistics, and can summarize them in // ...

  8. CSS实现图片等比例缩小不变形

    <img src="../images/bg1.jpg" alt="" /> img { /*等宽缩小不变形*/ /*width: 100%;*/ ...

  9. SQL语句中生成UUID方法

    SQL语句中生成UUID方法为UUID() 生成带横线UUID: select UUID()                         形如:abaffaca-fd55-11e5-b3d0-d2 ...

  10. Linux学习笔记——1.超级用户

    以超级用户工作:su su命令允许临时变换到任何一用户标识(如果拥有口令的话),并挂起当前shell,为新用户开启一个新的shell. su <user> 将当前用户标识harley变换为 ...