I am facing one issue while doing automation where the button is getting enable only after entering text in the field I need to click on CREATE Button after entering some text in the app name field. I have written code using JavaScript and it is entering value also but Button is not getting enable. The button is only getting enable when I am entering text using Keyboard.
Here is the code:
JavascriptExecutor jse = (JavascriptExecutor)driver; Object appname = jse.executeScript("return document.querySelector('body > sn-guided-app-creator').shadowRoot.querySelector('gac-focus-trap > gac-create-app-wizard').shadowRoot.querySelector('gac-wizard').shadowRoot.querySelector('gac-page-application-details').shadowRoot.querySelector('gac-page > section > form > div > div > gac-input.app-name-input').shadowRoot.querySelector('input');"); ((JavascriptExecutor)driver).executeScript("arguments[0].value=''", appname);
Screenshot: Page
This is serviceNow portal
Advertisement
Answer
To simulate keyboard strokes we have Actions class in Selenium.
Actions builder = new Actions(driver); builder.moveToElement(appname).sendKeys("Your name").build().perform();