Avestruz
Avestruz

Reputation: 27

Selenium Python: Invalid Selector in find_element_by_css_selector (Error)

I'm doing an automation to search a certain process on a website and collect information. When requesting data collection, it returns the following error: "Selenium Python: Invalid Selector in find_element_by_css_selector"

this is my code: chrome.find_element_by_css_selector('#\31 641215964292-0-uiGrid-003J-cell > div').text

This is the page source in the website: enter image description here

In yellow is the data I need to extract.

The id "\31" appears to contain the wrong value. But in that case how can I extract the data like this?

I would like to know the reason and solution.

Thanks for your time.

Please help me.

Upvotes: 1

Views: 139

Answers (2)

Arundeep Chohan
Arundeep Chohan

Reputation: 9969

elem=chrome.find_element(By.XPATH,"//div[@class='ui-grid-canvas']/div[2]/div/div/div").text

Would get you the first element with that number. It doesn't look like they have any unique identifiers except maybe the ui grid cell id.

Upvotes: 1

Candi Chiu
Candi Chiu

Reputation: 11

Try this css:

find_element_by_css_selector(".ui-grid-cell-contents .ng-binding .ng-scope")

If it's still not working, you can use xpath to check selenium can actually locate the element.

Upvotes: 1

Related Questions