How can I see the mouse pointer as it performs actions in Selenium?

Viewed 5227

I'm using Selenium Java WebDriver to automate UI tests. It works fine but it doesn't show the mouse pointer as it performs actions like clicking on a button. How can I make the mouse pointer visible as it moves on the page and clicks on a button?

2 Answers

You can highlight the elements that you are interacting with usings JS.

    String jsSyyle = "'3px solid red'";
    WebElement element; 
    JavascriptExecutor js = (JavascriptExecutor) driver;
    js.executeScript("arguments[0].style.border=" + jsSyyle, element);

The way to do that is with Actions see documentation.

For example:

Actions action = new Actions(webdriver);
WebElement myElement = webdriver.findElement(By.xpath("the/xpath/to/element"));
action.moveToElement(myElement).click().build().perform();

Hope this helps you!

Related