2

Is there a way for me to detect if the mouse pointer changes to the finger/hand pointer while using Selenium in Java?

stevek
  • 113
  • 1
  • 2
  • 7

1 Answers1

5

You can wait for the css value of the pointer to change.

// depends on which element you want to wait, here take <body> as an example
var wait = new WebDriverWait(driver, TimeSpan.FromMilliseconds(5000));
wait.Until(d => d.FindElement(By.TagName("body")).GetCssValue("cursor") == "pointer");

Original Post: Selenium: How can I wait until the cursor changes?

Cavan Page
  • 525
  • 2
  • 12
  • so instead of wait, would I use "pointer"? based on this link: https://stackoverflow.com/questions/3087975/how-can-i-make-the-cursor-a-hand-when-a-user-hovers-over-a-list-item – stevek Jul 18 '17 at 17:07
  • Thanks vor the solution! But in java, == returns wrong value. public boolean hasFingerCursor(WebElement rowElement){ Actions builder = new Actions(driver); builder.moveToElement(rowElement).perform(); return "pointer".equals(rowElement.getCssValue("cursor")); } – Mailis Toompuu Feb 18 '22 at 16:08