如何在Tripadvisor中使用气泡评分小部件中的评分? [英] How to handle the ratings within bubble rating widget with in Tripadvisor?

查看:79
本文介绍了如何在Tripadvisor中使用气泡评分小部件中的评分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种情况,我需要在

I hava a scenario in which i need to click fifth bubble of bubble rating widget within tripadvisor

The HTML code is:

<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>

I am trying with below code snippet:

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

This code hovers only first 3 bubbles and rest 4th,5th are not being clicked.

解决方案

To click for all the 5 star ratings within the Bubble Rating widget in https://www.tripadvisor.in/ using Selenium you have to induce WebDriverWait for the visibilityOfElementLocated() and you can use either of the following Locator Strategies:

  • 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();
    

  • Browser Snapshot:

这篇关于如何在Tripadvisor中使用气泡评分小部件中的评分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆