1

I am locating a textbox element inside shadow DOM using script(), and it works properly. Once I find the element, I want to enter a string into that box. I am trying to use input(), but since input() takes a locator and a value I am having issues using script() as a locator. Is this possible? I would appreciate any ideas or feedback on how to make this work.

mitymouse
  • 33
  • 2

1 Answers1

0

Just use JavaScript (element.value) itself, it should be the simplest way:

* script('.parent', "_.shadowRoot.querySelector('input').value = 'somevalue'")
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • what you suggested worked to some extent. but unfortunately it only places the string in the text box and the functionality of the text box is not "activated". Since this is a search text box, when the string is entered it automatically performs the search. With .value it only places the string inside the text box and the search is not performed. Is there any way to use input()? Since I am dealing with shadow DOM, I have to use script() to find the element. Can js be used inside input()? – mitymouse Jun 02 '20 at 23:36
  • @mitymouse give us a way to replicate please because we need to know if this is chrome or webdriver and fix it: https://github.com/intuit/karate/tree/develop/examples/ui-test - that said, you can fire a JS even manually and that should work: https://stackoverflow.com/a/60800181/143475 – Peter Thomas Jun 03 '20 at 02:24
  • the same issue is observed in chrome history search textbox. When I manually enter a string, the chrome history is updated. When I use js .value method, it places the string over the search textbox text instead of replacing it and performing the search. This is the line of code I am using to input the text: script("document.querySelector('#history-app').shadowRoot.querySelector('#toolbar').shadowRoot.querySelector('#main-toolbar').shadowRoot.querySelector('div#centeredContent > #search').shadowRoot.querySelector('#searchTerm > input#searchInput').value='karate'") – mitymouse Jun 04 '20 at 16:43
  • @mitymouse sorry, I'm not reading that - maybe others have more patience – Peter Thomas Jun 04 '20 at 18:51