1

Pardon me, I am really new to using python selenium library but i am in dire need of help.

I have the following html:

enter image description here

I would like to loop through all the divs under "search-results" and get the text contents and append to a list by indexes. Here is what I have so far:

o = []
for content in driver.find_elements_by_id('search-results'):
    o.append(content.find_element_by_xpath('.//div[@class="ng-tns-c1-1 ng-star-inserted"]').text)

While the following snippet works but it only provides me one out of ten result, only giving me the first result. Can not figure out how i can get all the results and have the texts as list within a list (or even dict).

Thank you very much in advance.

2 Answers 2

2

Maybe you can try this one.

o = []
for content in driver.find_elements_by_css_selector("#search-results div.ng-star-inserted"):
    o.append(content)
Sign up to request clarification or add additional context in comments.

Comments

1

you can try like this :

o = []
search = driver.find_element_by_css_selector("[tabindex]")
    
for content in search:
    o.append(content)

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.