When accessing the website in variable "url" it automatically accepts cookies, writes the dates and then clicks search but once it does it, 98 applications are shown making it click the first application. I made it so it goes back, redoes it so then it SHOULD click the second application, instead it returns an error
Can someone try and help make my script go back to the last page and click the second application?
Error:
[8796:7240:0913/132540.843:ERROR:install_util.cc(603)] Failed to read HKLM\SOFTWARE\Policies\Google\Chrome\MachineLevelUserCloudPolicyEnrollmentToken: The system cannot find the file specified. (0x2)
DevTools listening on ws://127.0.0.1:51391/devtools/browser/0f49248f-88a3-48b4-bf7c-975f7b52185a
Worked???
Traceback (most recent call last):
File "C:\Users\DBaldwin\Desktop\sel.py", line 34, in <module>
e.click()
File "C:\Users\DBaldwin\Anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Users\DBaldwin\Anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 628, in _execute
return self._parent.execute(command, params)
File "C:\Users\DBaldwin\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
self.error_handler.check_response(response)
File "C:\Users\DBaldwin\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
(Session info: chrome=68.0.3440.106)
(Driver info: chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 10.0.16299 x86_64)
Code:
import time
from bs4 import BeautifulSoup
from selenium import webdriver
url = "http://www.fareham.gov.uk/casetrackerplanning/applicationsearch.aspx"
driver = webdriver.Chrome(executable_path=r"C:\Users\DBaldwin\Desktop\chromedriver.exe")
driver.get(url)
driver.find_element_by_id("lnkAllowCookies").click()
def rerun():
driver.find_element_by_id("BodyPlaceHolder_uxLinkButtonShowAdvancedSearch").click()
time.sleep(3)
driver.find_element_by_id("uxStartDateDecisionTextBox").click()
driver.find_element_by_id("uxStartDateDecisionTextBox").clear()
driver.find_element_by_id("uxStartDateDecisionTextBox").send_keys("1/8/2018")
driver.find_element_by_id("uxStopDateDecisionTextBox").click()
driver.find_element_by_id("uxStopDateDecisionTextBox").clear()
driver.find_element_by_id("uxStopDateDecisionTextBox").send_keys("308/2018")
driver.find_element_by_id("BodyPlaceHolder_uxButtonSearch").click()
time.sleep(3)
rerun()
elements = driver.find_elements_by_class_name("searchResultsCell")
for e in elements:
e.click()
driver.back()
rerun()
print("Worked???")
Aucun commentaire:
Enregistrer un commentaire