Selnium Chrome WebDriver API使用

Selnium Chrome WebDriver API使用

使用

1.带参数使用

> selenium.webdriver.chrome.webdriver.WebDriver(executable_path='chromedriver',port=0, chrome_options=None, service_args=None,desired_capabilities=None, service_log_path=None)

2.不带参数使用:


> selenium.webdriver.remote.webdriver.WebDriver

使用ChromeDriver控制Chrome 浏览器
ChromeDriver下载

基本操作

使用Chrome选项配置


> create_options()

使用Chrome网络配置 返回 dict.

> get_network_conditions()

{‘latency’: 4, ‘download_throughput’: 2, ‘upload_throughput’: 2,
‘offline’: False}

指定 id.启动 Chrome

launch_app(id)

关闭Chrome browser 和ChromeDriver

quit()

设置网络参数

driver.set_network_conditions(offline=False, latency=5, # additional latency (ms) download_throughput=500 * 1024, # maximal throughput upload_throughput=500 * 1024) # maximal throughput

注意: ‘throughput’ 可以设置上传和下载

The WebDriver implementation.

使用WebDriver协议向远程服务器发送命令控制浏览器 参考

selenium.webdriver.remote.webdriver.WebDriver(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=False, file_detector=None)

基本:object
发送命令控制服务器 参考

属性

  • command_executor - 执行命令
  • error_handler - 处理错误

加入cookie参数:cookie_dict
dict对象包含key,value,可选项“path”, “domain”, “secure”, “expiry”

driver.add_cookie({
   ‘name’ : ‘foo’, ‘value’ : ‘bar’
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值