如何在 Tripadvisor 中处理气泡评级小部件中的评级?

How to handle the ratings within bubble rating widget with in Tripadvisor?

我有一个场景,我需要在 tripadvisor

中单击气泡评级小部件的第五个气泡

HTML代码是:

<span id="bubble_rating" class="ui_bubble_rating fl bubble_10" data-value="1" onclick="ta.userreview.common.trackFieldFocus(this); ">
<img src="https://static.tacdn.com/img2/x.gif" alt="Roll over, then click to rate">
</span>

我正在尝试使用以下代码片段:

Actions action = new Actions(driver);
WebElement element = driver.findElement(By.xpath("//span[@id='bubble_rating']"));
action.moveToElement(element).perform();

此代码仅悬停前 3 个气泡,其余第 4、5 个气泡未被点击。

要在 https://www.tripadvisor.in/ using you have to induce WebDriverWait for the visibilityOfElementLocated() and you can use either of the following Bubble Rating 小部件中点击所有 5 星级:

  • cssSelector:

    driver.get("https://www.tripadvisor.in/UserReviewEdit-g641714-d1156207-Club_Mahindra_Madikeri_Coorg-Madikeri_Kodagu_Coorg_Karnataka.html]");
    new Actions(driver).moveToElement(new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("span#bubble_rating"))), 50, 0).click().build().perform();
    
  • xpath:

    driver.get("https://www.tripadvisor.in/UserReviewEdit-g641714-d1156207-Club_Mahindra_Madikeri_Coorg-Madikeri_Kodagu_Coorg_Karnataka.html]");
    new Actions(driver).moveToElement(new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[@id='bubble_rating']"))), 50, 0).click().build().perform();
    
  • 浏览器快照: