python自动化脚本示例支付:Chrome脚本报错或出现脚本只执行一半就卡死情况

在使用Python进行Chrome自动化脚本时,可能会遇到ChromeDriver版本与Chrome版本不兼容导致的运行报错,或者由于页面加载缓慢造成脚本执行卡死。解决方案包括:更新ChromeDriver至与Chrome版本匹配,以及在关键步骤添加页面加载等待(如使用sleep函数)以确保页面完全加载后再执行后续操作。
摘要由CSDN通过智能技术生成

1.ChromeDriver版本和Chrome版本不兼容时,易出现运行报错(更换对应匹配的版本)

2.页面加载缓慢,出现执行一半就卡死情况(添加页面加载等待sleep)

在Chrome下运行脚本,报错(版本不兼容):  selenium.common.exceptions.WebDriverException: Message: session not created exception  from disconnected: received Inspector.detached event(Session info: chrome=52.0.2743.6)(Driver info: chromedriver=2.16.333243 (0bfa1d3575fc1044244f21ddb82bf870944ef961),platform=Windows NT 6.1 SP1 x86_64)

脚本:【

# coding=utf-8
from selenium import webdriver
from time import sleep

driver =webdriver.Chrome()
driver.get("https://m.edmbuy.com/")

driver.find_element_by_xpath("/html/body/footer/a[4]").click()
sleep(3)

driver.find_element_by_xpath("//*[@class

chromedriver,v2.24,支持chrome v52-54. ----------ChromeDriver v2.24 (2016-09-09)---------- Supports Chrome v52-54 Resolved issue 1497: GetLog fails when the current window is closed [['OS-All', 'Pri-0']] Resolved issue 1495: ChromeDriver crashes with "Check failed: !page_load_strategy_.empty()" [['OS-All', 'Pri-0']] Resolved issue 1463: SessionNotCreatedException: Runtime.evaluate missing 'wasThrown' on Chrome 54+ [['OS-All', 'Pri-0']] Resolved issue 1484: SendKeys of a Tab Key has no effect in Chrome 53 [['OS-All', 'Pri-1']] Resolved issue 1431: GetLog command does not work for Chrome 54+ [['OS-All', 'Pri-1']] Resolved issue 1411: sendKeys generates events that are missing some fields [['OS-All', 'Pri-1']] Resolved issue 1451: Chrome 54+ session not created exception: Runtime.executionContextCreated has invalid 'context' [['Pri-1']] Resolved issue 984: Extend ChromeDriver capabilities to cover network throttling feature from Chrome DevTools [['OS-All', 'Pri-2']] Resolved issue 1454: Net::ReadTimeout error on launching Canary v54 through RemoteWebDriver [[]] ----------ChromeDriver v2.23 (2016-08-04)---------- Supports Chrome v51-53 Resolved issue 1378: Android 6: Intitialization of Chrome driver fails when Chrome/Webview process is in running (R) state [['OS-Android', 'Pri-1']] Resolved issue 1379: Chromedriver does not catch all available browser console log entries [['OS-All', 'Pri-2']] ----------ChromeDriver v2.22 (2016-06-06)---------- Supports Chrome v49-52 Resolved issue 1348: Timeout error while navigating to URL on Chrome 51+ [['OS-All', 'Pri-0']] Resolved issue 1381: Timeout error occurs when alert dialog is displayed on Chrome 52+ [['OS-All', 'Pri-1', 'merge-merged-2743']] Resolved issue 1339: Failure when executing JS in a content script context [['OS-All', 'Pri-1']] Resolved issue 1387: ChromeDriver hangs when calling driver.get() for same-process navigations [['OS-All', 'Pri-1']] Resolved issue 1365: Touch emulation is not working under mobile emulation
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值