I want to move the cursor on xpath element given below so that I can validate the colour changes but I am getting below error : org.openqa.selenium.interactions.MoveTargetOutOfBoundsException:
WebElement ele = browser.driver.findElement(By.xpath("(//li/a[contains(@class,'gn__cta')])[1]"))
((JavascriptExecutor) browser.driver).executeScript("window.scrollBy(2900,0)",ele)
Actions action = new Actions (browser.driver);
WebDriverWait wait = new WebDriverWait(browser.driver, 50);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("(//li/a[contains(@class,'gn__cta')])[1]")));
((JavascriptExecutor) browser.driver).executeScript("arguments[0].scrollIntoView(true);",element)
sleep(10000)
action.moveToElement(element).click().build().perform()
Tried to use moveByOffset() function ended up with the same error :
action.moveToElement(browser.driver.findElement(By.xpath("(//li/a[contains(@class,'gn__cta')])[1]")), 0, 0).clickAndHold().moveByOffset(0, 100).release().build().perform();