Is there a way for me to detect if the mouse pointer changes to the finger/hand pointer while using Selenium in Java?
Asked
Active
Viewed 4,398 times
2
-
I think I have understood your question but I was wondering what can be a valid usecase/business-case. Thanks – undetected Selenium Jul 18 '17 at 18:01
-
See: [How do I do X?](https://meta.stackoverflow.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do-i-do-x) The expectation on SO is that the user asking a question not only does research to answer their own question but also shares that research, code attempts, and results. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! See also: [ask] – JeffC Jul 18 '17 at 18:26
1 Answers
4
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
- 505
- 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