onchange event does not get fired on selenium type command

前端 未结 8 2123
予麋鹿
予麋鹿 2020-12-17 21:47

I am typing some value, on change do a total. But somehow, this event is not getting fired with selenium type command.

I also tried typeKey and typeAt ..But no succe

8条回答
  •  悲哀的现实
    2020-12-17 22:25

    I faced the same issue but able to resolve this issue. Below code is for enter text in input field and fire onchange event.

    WebElement textBox = driver.findElement(By.xpath(xpath));
    textBox.sendKeys("Test");
    ((JavascriptExecutor) driver).executeScript("arguments[0].onchange", 
      Arrays.asList(textBox));
    

    Hope it will work!

提交回复
热议问题