1

I do not understand why Selenium does not allow me to search for elements within elements. I want to create a new element called property that contains the subset of data I would like to obtain from 'main' which I extracted from the website. I heard Selenium decented find_element so I am unsure what else to use here.

website for reference: https://www.hellolanding.com/s/austin-tx/apartments/furnished

from ast import Try
from gettext import find
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time

driver = webdriver.Chrome(executable_path="C:/Users/Carson/Desktop/chromedriver.exe")
driver.get("https://www.hellolanding.com/s/austin-tx/apartments/furnished")

try:
    main = WebDriverWait(driver, 5).until(
        EC.presence_of_element_located((By.ID,'search-home-list-wrapper'))
    )
    property = main.find_elements(By.CLASS_NAME, 'transition-delay[200ms] relative flex flex-col mb-6 w-full overflow-hidden e1mngczp3 rounded-t-lg css-12puc69 e4dpi0y0')
    
    print(property.text)
    print("successsssssssssssssssssssssssssssss")
    driver.quit()

except:

    driver.quit()
    print("failed")
2
  • Which subset of data you are looking for? Commented Aug 3, 2022 at 2:48
  • @undetectedSelenium I am looking to get data for each unit via a for loop for property in properties and print out first the name, then the beds, baths, and sq ft. Commented Aug 3, 2022 at 3:17

1 Answer 1

2

You are doing find_elements() which returns a list of elements, not just 1. So your call of property.text will raise an exception. You print "fail" instead of the error so it hurts when debugging

You have an invalid class with the long name. Just try to use hte common one like "e1mngczp3"

properties = main.find_elements(By.CLASS_NAME, 'e1mngczp3')
for property in properties:
    print(property.text)
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.