Search code examples
javaselenium-webdriverace-editor

How to interact with Ace Editor using Selenium WebDriver


I have been struggling to write a clean, working code that interacts (write a text within) with an Ace Editor text area in Java with WebDriver.

I am able to find it using an XPATH, but clicks and send keys are not working as expected. Is there a proper way to interact with AceEditor ? What is it ? Do I have to use JavascriptExecutor ?

I have been using only WebDriver so far and I would rather keep it that way.

The question has been asked on this post but no satisfying answer has been given, especially in Java.

The solution that would seem the more viable to me at the moment is to click on the AceEditor using its XPATH, then use Actions to copy and paste a pre-copied text into the editor. This is something I really want to avoid.


Solution

  • The best fix for me so far was to get somehow the selection inside the AceEditor and then using :

        webDriver.switchTo().activeElement().sendKeys(string);
    

    This will just write where the selection is. Not very clean but does the job