I am trying to extract userid, rating and review from the following site using selenium and it is showing "Invalid selector error". I think, the Xpath I have tried to define to get the review text is the reason for error. But I am unable to resolve the issue. The site link is as below:
Also, The xpath that I tried to trace is from following HTML
CodePudding user response:
You are seeing the classic error of...
as find_elements_by_xpath('//*[@id="' x '"]]/div[3]/p[2]/text()')[0]
would select the attributes, instead you need to pass an xpath expression that selects elements.
You need to change as:
user_message = self.driver.find_elements_by_xpath('//*[@id="' x '"]]/div[3]/p[2]')[0]
References
You can find a couple of relevant detailed discussions in: