Home > Net >  Python Selenium. Unable to locate elements
Python Selenium. Unable to locate elements

Time:03-22

I've been trying for hours to extract the text from an unknown number of elements on a website. I uploaded 2 pictures so you can see similarities of the elements to identify them. They have the same class name, for example. The black underlined text is basically the text I want to extract.

I haven't even come to the step of extracting the text because I'm not able to even find the element.

Here is one of the things I've tried:

a=driver.find_elements_by_class_name("pooVf")
print(a)

The result I got was '[]'.

I have also tried to use css selector

a=driver.find_elements_by_css_selector("a.pooVf.prDW")
print(a)

Also got '[]'.

I have no clue how to add the html code as text. Everytime I tried it didn't work.

CodePudding user response:

Did you try to use the function "text"?

driver.find_elements_by_css_selector(".....").text

CodePudding user response:

Have you tried using the element's XPath instead of its CSS selector or class name? I would've left this as a comment, but I don't have enough reputation.

  • Related