0

I am trying to test our application which is in Angular. I wanted to know what is the difference between. WebElement stateSelect = driver.findElement(By.id("name")); stateSelect.sendKeys("Testing Angular"); and

WebElement stateSelect = driver.findElement(By.id("name")); ((JavascriptExecutor) driver).executeScript("arguments[0].value='testing angular interpolation';arguments[0].click()", stateSelect);

When i am testing with sendKeys interpolation on the particular webElement works, i.e it shows the updated value on interpolation while if i do the latter updating the value and try interpolation on that particular value it doesn't work. I would like to know how i could achieve sendKeys functionality using executeScript.

  • 2
    For testing purpose DO NOT use JavascriptExecutor to interact with web-page since it won't simulate real-user behavior! – Curious koala Aug 16 '22 at 06:17
  • Does this answer your question? [WebDriver click() vs JavaScript click()](https://stackoverflow.com/questions/34562061/webdriver-click-vs-javascript-click) – Prophet Aug 16 '22 at 07:29
  • This question was asked several times and has been answered a long time ago with great explanations – Prophet Aug 16 '22 at 07:30
  • 1
    @Prophet this https://stackoverflow.com/a/62871182/15347640 answers my question. – suhail shaik Aug 16 '22 at 10:27

0 Answers0