1

I'd like to get the elements by Selenium as the attached pic:

ess-cell class="data-numeric"

However, the following code didn't work even though:

find_element_by_tag_name('div')

part works correctly. Does anyone know why?

row.find_element_by_tag_name('div').find_element_by_tag_name('div').find_elements_by_tag_name('ess-cell')

enter image description here

1
  • row.find_element_by_tag_name('div').find_element_by_tag_name('div').find_elements_by_tag_name('ess-cell') parts works, that's fine. What is the error though ? Commented Feb 19, 2022 at 14:11

1 Answer 1

1

To get the elements <ess-cell class="data-numeric"...> you can use either of the following Locator Strategies:

  • Using css_selector:

    elements = row.find_elements(By.CSS_SELECTOR, "div > div ess-cell.data-numeric")
    
  • Using xpath:

    elements = row.find_elements(By.XPATH, "./div/div//ess-cell[contains(@class, 'data-numeric')]")
    

Ideally you have to induce WebDriverWait for presence_of_all_elements_located() and you can use either of the following locator strategies:

  • Using CSS_SELECTOR:

    elements = WebDriverWait(row, 20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "div > div ess-cell.data-numeric")))
    
  • Using XPATH:

    elements = WebDriverWait(row, 20).until(EC.visibility_of_all_elements_located((By.XPATH, "./div/div//ess-cell[contains(@class, 'data-numeric')]")))
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
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.