selene
selene copied to clipboard
use ActionChains to clear an input instead of `.clear()`
Sometimes Selenium's .clear() method doesn't work to delete the text in an input element.
In the element.py .set() method (https://github.com/yashaka/selene/blob/master/selene/elements.py#L353), perhaps we should be using ActionChains to clear inputs before we type into them, as shown in https://github.com/SeleniumHQ/selenium/issues/6741
@dskard thank you, but it’s a very specific case! So I think for such situations user is able to use direct selenium calls
I would agree that the original post was very specific, but the solution seems to be the more general solution that people should be aiming to implement. From that conversation, my understanding is that the .clear() method will only work for a subset of input fields a developer may encounter. The ActionChains solution more closely models human behavior, which is what allows it to work on input fields where the .clear() method is currently failing.
If we stick with a .set() method that relies on the .clear() method under the hood, we force developers using Selene to write their own ActionChains code to clear the input and then use a .send_keys() call to populate the input. Doing this for one input is probably ok. Doing this for a form with multiple inputs would get verbose. My guess is people would prefer the concise .set() method that reliably clears the input field before typing into it.
Does that match with your understanding of the conversation or are there other details I am missing?