0

I am trying to create a python dictionary from elements on a web page. The sleeps are in to allow my poor internet connection and the glacially slow website to catch up. So far I have

driver.get("https://my.crawley.gov.uk/en/service/check_my_bin_collection?accept=yes&consentMessageIds[]=24")
WebDriverWait(driver,30).until(EC.frame_to_be_available_and_switch_to_it('fillform-frame-1'))

WebDriverWait(driver,30).until(EC.element_to_be_clickable((By.XPATH,'//*[@id="PostcodeSearch"]')))
sleep(1)
elem = driver.find_element_by_id("PostcodeSearch")
elem.clear()
elem.send_keys("RH10 7AB")
sleep(2)
WebDriverWait(driver,30).until(EC.element_to_be_clickable((By.XPATH,'//*[@id="Choose_Address"]')))
sleep(1)
elem = driver.find_element_by_id("Choose_Address")
elem.send_keys("12")
sleep(5)
elem = driver.find_element_by_class_name("nextText")
elem.click()
sleep(3)

collection_dict = {}

collectiondetails = {"nextrubbish" : (driver.find_element_by_name("rubbishDateNext").getAttribute("value"))}
                                      
print(collectiondetails["nextrubbish"]) 

However I'm struggling to get a value for the rubbishDateNext result. Inspecting the element, it would appear it's not actually got a value and just a load of validation. Ideally, I'd like to have the dictionary value for nextrubbish print as Friday 26 June

How do I get this out and into Python?

2
  • What is returned by driver.find_element_by_name("rubbishDateNext").getAttribute("value")? Commented Jun 25, 2020 at 13:06
  • @AlexeyR. it returns AttributeError: 'WebElement' object has no attribute 'getAttribute' Commented Jun 25, 2020 at 13:22

1 Answer 1

1

Instead of (driver.find_element_by_name("rubbishDateNext").getAttribute("value"))

use

(driver.find_element_by_name("rubbishDateNext").get_attribute("value"))

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.