I am testing a text field set with setText() but after its execution, the focus is still on the element I wrote in and then the web page doesn’t react (I am trying to trigger an error message with a field that I fill with the string “”).
I’ve tried to use sendKeys(myTestObject, Keys.chord("", Keys.TAB)) but a strange character appears in the next field and I don’t want to.
Is it a good way to do this kind of task? Is there a proper way to do it?
To focus an object that is not a a text field doesn’t blur the text field that is in focus and I don’t want to interact with a text field I am not actually testing to not pollute its test. Don’t know if it is right?
That said however, I need to comment on this part of your answer…
Possibly. You can focus on anything that can be “tabbed to” via the keyboard. Perhaps you chose an “otherTo” that cannot receive focus?
Yes, it seems that except the three text field set I want to test, no element can’t be “tabbed to” in the page I am working on.
At first I was passing the focus to the next text field set, and when I reached the last one I was passing the focus to the first, a little bit like in a cyclic permutation. As I was passing the focus to another text field, I thought why not write in it as well and test error message when all of them were filled. But with my colleagues we changed our minds and decided to test only one text field at once. And passing the focus, which I interpret as interacting with another field then became weird to me. That’s why I groped for a different way to proceed.
Code a line in a language I don’t know to call an other language that is also unknown to me was such a funny idea
Do you think this way is simple enough to be used?
It’s “reasonable” and you have reasoned it out very well.
But, there are caveats (see link below), as you’ve already hinted at. If your reasoning stands above all other possible solutions, then by all means use it (you might want to document that reasoning using // comments in the source).