Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 基于Selenium的代码在Chrome更新后不起作用_Python_Selenium_Selenium Webdriver - Fatal编程技术网

Python 基于Selenium的代码在Chrome更新后不起作用

Python 基于Selenium的代码在Chrome更新后不起作用,python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,我将浏览器从Chrome75升级到了77,并使用了Selenium驱动程序。我编写的代码不再能够在网站中导航,并且总是在不应该的同一阶段失败 这两个版本之间是否有需要在代码中编辑的更改 我编写了一个程序来获取车辆注册检查器,将其输入政府注册检查器,并返回与该注册相关的汽车的三位数据 这是一行不再工作的代码 python_button = driver.find_elements_by_xpath("//input[@data-val='true'][@type='radio']")[0] pyt

我将浏览器从Chrome75升级到了77,并使用了Selenium驱动程序。我编写的代码不再能够在网站中导航,并且总是在不应该的同一阶段失败

这两个版本之间是否有需要在代码中编辑的更改

我编写了一个程序来获取车辆注册检查器,将其输入政府注册检查器,并返回与该注册相关的汽车的三位数据

这是一行不再工作的代码

python_button = driver.find_elements_by_xpath("//input[@data-val='true'][@type='radio']")[0]
python_button.click()
似乎无法通过此阶段-即使链接按钮的html似乎是正确的。无论reg是否正确,我的脚本都返回return([vehicleReg,“vehicle not found”])

我收到了错误信息

python_button=driver.find_elements_by_xpath(//input[@data val='true'][@type='radio'])[0]

索引器:列表索引超出范围

我的代码是:

def车辆EGTEST('LK02USP'):


这对我很有效,请尝试最大化浏览器
驱动程序。最大化\u window()
。您还应该添加一些等待。我现在已将代码更改为此。。。仍然总是返回vehicle not found error(车辆未找到错误)-它无法在等待功能后执行代码。您可以尝试
将异常捕获为e
打印(e)
,并将其添加到问题中吗?我得到的只是“消息”:打开的网页永远无法执行以下操作:python\u button=driver.find\u elements\u by\u xpath(“//输入[@data val='true'][@type='radio']]”[0]python_按钮。单击()我现在收到以下消息:消息:没有这样的元素:无法找到元素:{“方法”:“css选择器”,“选择器”:“[name=“Vrm”]”(会话信息:chrome=77.0.3865.90)
from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://vehicleenquiry.service.gov.uk")

driver.find_element_by_name("Vrm").send_keys(vehicleReg)

python_button = driver.find_elements_by_xpath("//button[@name='Continue'][@type='submit']")[0]
python_button.click()

python_button = driver.find_elements_by_xpath("//input[@data-val='true'][@type='radio']")[0]
python_button.click()

python_button = driver.find_elements_by_xpath("//button[@name='Continue'][@type='submit']")[0]
python_button.click()