Идентификатор, который вы используете, является динамическим c. Попробуйте использовать следующее xpath
.
new Actions(driver).moveToElement(new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[text()='Hotel Ratings']/following::span[1]"))), 50, 0).click().build().perform();
new Actions(driver).moveToElement(new WebDriverWait(driver, 30).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[text()='Hotel Ratings']/following::span[2]"))), 50, 0).click().build().perform();
new Actions(driver).moveToElement(new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[text()='Hotel Ratings']/following::span[3]"))), 50, 0).click().build().perform();
Снимок браузера.
ОБНОВЛЕНИЕ :
Для браузера firefox
вам нужно scroll
, чтобы получить фокус element
, а затем выполнить операцию.
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[text()='Hotel Ratings']/following::span[1]"))));
new Actions(driver).moveToElement(new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[text()='Hotel Ratings']/following::span[1]"))), 50, 0).click().build().perform();
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[text()='Hotel Ratings']/following::span[2]"))));
new Actions(driver).moveToElement(new WebDriverWait(driver, 30).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[text()='Hotel Ratings']/following::span[2]"))), 50, 0).click().build().perform();
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[text()='Hotel Ratings']/following::span[3]"))));
new Actions(driver).moveToElement(new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[text()='Hotel Ratings']/following::span[3]"))), 50, 0).click().build().perform();