Reputation: 51
I updated my browser from Chrome 75 to 77, and now my code has stopped working - this is after updating the Selenium driver - it still runs it does just not do what it did before.
I wrote a programme to take a vehicle reg checker, enter it into the government reg checker and return three bits of data to do with the car linked to that reg.
It doesn't seem to get to the page after the reg has been accepted - the one where you click yes then continue.
I've tried to remove the try and except clauses which seems to fix it... but then sort of ruins what I'm trying to do!
def vehicleRegChecker(vehicleReg):
from selenium import webdriver
try:
driver = webdriver.Chrome()
driver.get("https://vehicleenquiry.service.gov.uk/ConfirmVehicle")
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()
fuel_type = driver.find_element_by_id('FuelTypeShown').text
years_of_manufacture = driver.find_element_by_xpath('//li[.//*[contains(text(), "Year of manufacture")]]//strong').text
cc = driver.find_element_by_xpath('//*[@id="CylinderCapacity"]//strong').text
print(fuel_type)
print(years_of_manufacture)
print(cc)
# driver.quit()
return([vehicleReg,fuel_type, years_of_manufacture, cc])
except Exception:
# driver.quit()
return([vehicleReg, "vehicle not found"])
Upvotes: 0
Views: 931
Reputation: 2130
go here
download the one that suits you, for chrome 77, it's the last choice
Upvotes: 0
Reputation: 2198
You're likely using an older ChromeDriver version not compatible with Chrome 77. See ChromeDriver docs which says:
If you are using Chrome version 77, please download ChromeDriver 77.0.3865.40
Upvotes: 2