0

How to input text in a text-box that is under Shadow-root in a web page using protractor or selenium? Anything would be helpful. I am trying to enter values in a text-field with xpath and xpath is correct because I have validated it in console.

1 Answers1

1

Just using javascript in the web console you can use the following:

document.querySelector('message-list').shadowRoot.querySelector('.textbox').querySelector('textbox').value = 'hello'

To run it with appium you need to use driver.executeScript

eisbehr
  • 12,243
  • 7
  • 38
  • 63
  • Be aware that this will only work if the shadowRoot was created "open" is the developer chooses to do this: `this.attachShadow({mode: 'closed'}); then `element.shadowRoot` will return `null` – Intervalia Aug 06 '18 at 15:37