Working on e2e automation test using Selenium.
The editor is not a text area. Each line is a separated div element.
Given some "code" in string format(or retrieve it from some static files) how can I do the input/edit/delete? Anyone please has some ideas or experience? Do I have to parse the input and update the inner html following the original format?
The editor I/O is done via a <textarea> that always has focus. If you click in an editor, the browser focus resides in a very tiny <textarea>. In 0.8.3. the textarea is placed at the top left of the editor, in the upcoming release the <textarea> will move with the editor's primary cursor (when it is visible). You can find the <textarea> by clicking in an editor and using document.activeElement in a browser console.
To simulate editing, etc. you would need to send correct browser events to the <textarea>.
Finding this issue helped me a lot, thank you for adding the notes. I suppose there are two items here:
<textarea> elementI think the first is clearly out of scope as far as documentation goes, but I is there somewhere the second point is / could be documented?.
On the first point, in case this helps anyone else perusing this issue, sending the events to the browser could use seleniums sendKeys or (in my case) WebdriverIO's setValue method. I have a spectron test that does this:
async function setText(client: SpectronClient, text: string) {
await client.setValue(`.monaco-editor textarea`, text);
}
@joaomoreno Perhaps you remember what you had to do to get spectron to like our editor?
This is what we're doing right now:
Most helpful comment
This is what we're doing right now:
https://github.com/Microsoft/vscode/blob/314cc521d8ce0c55773850ef520095afde33a62c/src/vs/platform/driver/electron-browser/driver.ts#L154:L172