-1

I am trying to sendKeys in input textbox in protractor. It's in a shadow-root and there are three input textbox.

deep
  • 11
  • 4
  • Have you checked https://stackoverflow.com/questions/56380091/how-to-interact-with-the-elements-within-shadow-root-open-while-clearing-brow/56381495#56381495 – supputuri Sep 09 '19 at 02:29
  • Please click on `edit` under the tags in your question. Then you should be able to add the html between `~~~ ~~~` . Also please open a separate question if your question is different for the benefit of future visitors. – supputuri Sep 09 '19 at 20:01

1 Answers1

1

Here is the javascript that you have to run to return the element.

document.querySelector('tahiti-app').shadowRoot.querySelector('vaadin-text-field').shadowRoot.querySelector("input[aria-labelledby='vaadin-text-field-label-1']")

Refer to this answer for detailed information how to work with shadowroot elements (though it's not specific to protractor).

Try the below code:

browser.executeScript("document.querySelector(\"tahiti-app\").shadowRoot.querySelector(\"vaadin-text-field\").shadowRoot.querySelector(\"input[aria-labelledby='vaadin-text-field-label-1']\").value=\"1234\";"
).then( function(){
 console.log('Done'); 
});
supputuri
  • 13,644
  • 2
  • 21
  • 39
  • Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackoverflow.com/rooms/199216/discussion-on-answer-by-supputuri-how-to-write-deepcss-for-input-textbox-in-prot). – Samuel Liew Sep 10 '19 at 00:20
  • Thanks @SamuelLiew, I wasn't sure if the OP can join the Chat as he does not have enough reputations. And if you don't mind can you please let me know link which gives the info how to move the comments to chat. – supputuri Sep 10 '19 at 01:27
  • Moderator created chatrooms grant access to all prior participants. See https://chat.stackoverflow.com/rooms/info/199216/discussion-on-answer-by-supputuri-how-to-write-deepcss-for-input-textbox-in-prot?tab=access – Samuel Liew Sep 10 '19 at 01:36
  • trying to check if the radio button is already checked or not but its not working.browser.executeScript("document.querySelector(\"tahiti-app\").shadowRoot.querySelector(\"tahiti-groups\").shadowRoot.querySelector(\"vaadin-radio-button[value='plant']\").checked").then(function () { console.log('Plant Radio button is already checked'); – deep Sep 13 '19 at 14:29