Member-only story
Sending text to fields for which no known locators.
Question:
https://sqa.stackexchange.com/questions/42251/how-to-interact-with-ngx-monaco-editor
Answer:
If you are not sure about the locator, then you can use the action class sendKeys method to interact with the field.
Here, it interacts with the active (currently focused ) element.
So the first step is to bring the element to focus, this can be done by just clicking it:
await browser.get('https://stackblitz.com/edit/ngx-monaco-editor-example')
await browser.sleep(10000)
await $('[class="view-line"]').click()
await browser.sleep(4000)
Now you can see the cursor is at the below place:
Now you can interact with the element using browser.actions():
await browser.actions().sendKeys('This is test').perform();
this will send input to the currently active element:
Now let us look deeper to find out the locator:
We now know that the sendKey using action works, so we can find the locator from the active element:
The outerHTML of the active element gives the locator:
await $('[class="view-line"]').click()
let test =…