0

I am writing a selenium program to parse reviews from costco webpage. https://www.costco.com/irobot-roomba-985-wi-fi-connected-robot-vacuum.product.100428595.html

I want to sort the reviews and fetch the sorted reviews one page at a time. The issue is the select dropdown list is hidden under a button element and only becomes visible when the mouse hovers over it. I am able to get to the button but not able to access the select element.

DOM:

<div class="bv-dropdown"> 
 <div class="bv-dropdown-target" role="menu"> 
  <span id="bv-dropdown-select-reviews" class="bv-dropdown-label"> Sort by: </span> 
  <button type="button" class="bv-focusable" aria-haspopup="true" aria-expanded="false" role="menuitem" aria-labelledby="bv-dropdown-select-reviews bv-dropdown-title-reviews"> 
   <span id="bv-dropdown-title-reviews" class="bv-dropdown-title">   Most Relevant           </span> 
   <span class="bv-dropdown-arrow" aria-hidden="true" role="presentation"> ▼ </span> 
   <span class="bv-off-screen">Menu</span> 
  </button> </div> 
  <select class="bv-select-cleanslate bv-dropdown-select" aria-hidden="true" aria-labelledby="bv-dropdown-select-reviews" tabindex="-1">  
   <option value="relevancy" selected=""> Most Relevant </option>  
   <option value="mostHelpful"> Most Helpful </option>  
   <option value="positive"> Highest to Lowest Rating </option>  
   <option value="negative"> Lowest to Highest Rating </option>  
   <option value="mostRecent"> Most Recent </option>  
  </select> 
</div>

My code snippet :

WebElement sortSelection = driver.findElement(By.xpath("//div[@class='bv-dropdown']"));

    Actions action = new Actions(driver);
    action.moveToElement(sortSelection).moveToElement(driver.findElement(By.xpath("//select[@class='bv-select-cleanslate bv-dropdown-select']/option[@value = 'mostRecent']"))).click().build().perform();

Please help!!!

Jeet
  • 1
  • 1
  • Is this different from the following answer, https://stackoverflow.com/questions/44920201/expected-condition-failed-waiting-for-visibility-of-element-located-by-by-xpath – Steven Friedman Jan 04 '20 at 19:21
  • Yes, the main issue is the drop-down is hidden and my code is not able to access the element – Jeet Jan 04 '20 at 19:40

0 Answers0