I'm currently learning this selenium beginners course. In booking.com based on the tutorial, you can find the id of the element but now that the tutorial was posted several months ago perhaps the web developer made some changes and all I can find now is this line of code and the is same as those other filter options too I find that not unique
<div data-filters-group="class" >
here's what I did
def apply_star_rating(self):
star_filtration_box = self.driver.find_element_by_css_selector(
'div[data - filters - group = "class"]'
)
CodePudding user response:
You are using this css
div[data - filters - group = "class"]
you have extra spaces with -
Please try this CSS :
div[data-filters-group='class']
or XPath
//div[@data-filters-group='class']
Please check in the dev tools
(Google chrome) if we have unique entry in HTML DOM
or not.
Steps to check:
Press F12 in Chrome
-> go to element
section -> do a CTRL F
-> then paste the css/xpath
and see, if your desired element
is getting highlighted with 1/1
matching node.
CodePudding user response:
Try the below XPath to see if at least the first of the filter fields get highlighted.
//*[@div data-filters-group="class"][1]