Each of the "7-pack" search results here contains a number of reviews e.g. "5 reviews", No reviews" etc.
The class name for each is fl r-iNTHbQvDybDU
. It contains a space, so if I try find_elements_by_class_name(), I get:
InvalidSelectorError: Compound class names not permitted
According to other answers on here, all I needed to do was remove the space and retry. No luck - an empty list
So I try find_element_by_css_selector()
:
find_elements_by_css_selector(".fl.r-iNTHbQvDybDU")
Still no luck - empty list. What would you try next?
Selenium By.This method makes it possible to locate an element by referencing its class name. The class() method is found inside the By class of the Selenium WebDriver JavaScript library. The class also contains other alternative methods for locating elements. let loginBtn = await driver.
ID locator in Selenium is the most preferred and fastest way to locate desired WebElements on the page. ID Selenium locators are unique for each element in the DOM. Since IDs are unique for each element on the page, it is considered the fastest and safest method to locate elements.
A class name can't have spaces. When you have a space-separated string in your class attribute, you're always giving your element several classes.
How about this:
browser.find_elements_by_css_selector("div[class='fl r-iNTHbQvDybDU']")
This assumes tag for the class = div
.
If it is something else - otherwise replace div w/ the appropriate tag..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With