I have been trying to parse for this certain piece of text in a webpage with selenium and cannot figure out why I cannot display the text I want. The snippet of code on the page is as such
<div id="BVRRRatingOverall_Review_Display" class="BVRRRating BVRRRatingNormal BVRRRatingOverall">
<div class="BVRRLabel BVRRRatingNormalLabel"/>
<div class="BVRRRatingNormalOutOf">
<span class="BVRRNumber BVRRRatingNumber">4</span>
<span class="BVRRSeparatorText">out of</span>
<span class="BVRRNumber BVRRRatingRangeNumber">5</span>
</div>
</div>
Where I want to get the text “4 out of 5”. I am using firebug to check my xpath/cssSelector is valid but selenium still cannot find the text. I have tried different implementation of waits and cssSelectors to try and remedy this too. Nothing seems to work. The code I am currently working with is
String Url2 = "http://www.walmart.com/catalog/allReviews.do?product_id=16207347";
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get(Url2);
System.out.println("test" + driver.findElement(By.cssSelector(".BVRRSeparatorText")).getText());
Where I am just trying to print “test out of” to screen but I only print “test”. Does anyone know how I can get this to work? Ive looked around the internet but nothing I found worked.
The equivalent xpath I am also testing for this case is //*[@id='BVRRRatingOverall_Review_Display']/div[@class='BVRRRatingNormalOutOf']/span[@class='BVRRSeparatorText']
Edit* I think the problem is because the text is never actually displayed on the webpage. Its text that would only be seen upon hovering over the element on the page.
You can get the alt text of the ratings star image instead.
The Ruby syntax is (not sure the exact syntax for the other languages but similar should exist):