I wrote the following method to clear the input field:

/** * Очищает поле ввода у элемента * * @param locator локатора элемента xpath или css */ public AbstractPage sendButtonPressesBackSpace(String locator) { logger.info(String.format("Очищает поле ввода у элемента {%s}", locator)); SelenideElement el = getSelenideElement(locator); while (el.val().length() != 0) el.sendKeys(Keys.BACK_SPACE); return this; } 

This is done because Angular processes only user actions and setValue("") does not work properly ...

The question is: Does Selenium or Selenide have methods for zeroing the element? for I could not find them

  • as an option, you can execute the script (Selenium) and clear the field in it. And in theory it should work right. - Tsyklop pm
  • what script I'm waiting for specific code examples - sevnight pm
  • @Tsyklop, so? do you mean by a script some functions selenium or method executejavascript which assumes javascript code? I'm looking for a function that simulates input field clearing events, similar to the one I wrote. the question is, is there such already finished in some library, or is my function relevant. for as I said earlier, Angulyar may not process the assignment of an empty string to a field. The code will of course work and the field will be cleared, but after sending the form, the field will remain filled - sevnight
  • Yes, I mean the JS code to execute. The thing is that there you can remove the value and trigger an onChange event or something else that will help the Angular to understand that the value has changed. - Tsyklop
  • @Tsyklop, yes, I do it with simple input fields, but not in all cases it works .. so I come to the sendKeys(Keys.BACK_SPACE) method - sevnight

0