Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97771

How to set onchange event or dispatch event?

$
0
0

Trying to set some value in the textbox & dispatch event.

browser.executeScript(`document.querySelector("body > moo-shell > auto-app").shadowRoot.querySelector("section > auto-config").shadowRoot.querySelector("section:nth-child(2) > div > div:nth-child(2) > section:nth-child(1) > auto-schedules-field").shadowRoot.querySelector("div > vaadin-ext-time-picker:nth-child(1)").shadowRoot.querySelector("vaadin-combo-box-light > vaadin-time-picker-text-field").shadowRoot.querySelector("div > div:nth-child(2) > slot:nth-child(2) > input").value = "abcd";`);
//Dispatching change event
browser.executeScript(`document.querySelector("body > moo-shell > auto-app").shadowRoot.querySelector("section > auto-config").shadowRoot.querySelector("section:nth-child(2) > div > div:nth-child(2) > section:nth-child(1) > auto-schedules-field").shadowRoot.querySelector("div > vaadin-ext-time-picker:nth-child(1)").shadowRoot.querySelector("vaadin-combo-box-light > vaadin-time-picker-text-field").shadowRoot.querySelector("div > div:nth-child(2) > slot:nth-child(2) > input").dispatchEvent(new Event('change', { 'bubbles': true }));`);

var clickAddButton = `document.querySelector("body > moo-shell > auto-app").shadowRoot.querySelector("section > auto-config").shadowRoot.querySelector("section:nth-child(2) > div > div:nth-child(2) > section:nth-child(1) > auto-schedules-field").shadowRoot.querySelector("div > vaadin-button").shadowRoot.querySelector("#button").dispatchEvent(new Event('change', { 'bubbles': true }));`;
browser.executeScript(clickAddButton);
//Dispatching change event after clicking the add button
browser.executeScript(`document.querySelector("body > moo-shell > auto-app").shadowRoot.querySelector("section > auto-config").shadowRoot.querySelector("section:nth-child(2) > div > div:nth-child(2) > section:nth-child(1) > auto-schedules-field").shadowRoot.querySelector("div > vaadin-button").shadowRoot.querySelector("#button").click();`)

//Expected Result: Input box should turn red
//Actual Result: Value passes in the input box & clicked Add button but inputbox doesnot 
//turns red...same execution doing manually input box turns red.```

Viewing all articles
Browse latest Browse all 97771

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>