03-20-2017 12:26 PM
I wrote python script for a simple test scenario. Have to enter username and password in the edit box. I used the below code
When i run this , it enters the username, password and when it comes to click the save button the username got wiped off . Dont know how or why.
In the same example if i use username.Keys("admin") , the script works fine. Can anyone let me know why the SetText() is behaving differently in this scenario
03-20-2017 12:59 PM - edited 03-20-2017 12:59 PM
SetText frequently behaves differently than Keys. SetText is trying to set the field to the given value and Keys is just typing as if someone was using the keyboard.
SetText may or may not work (as you have seen) depending on the field you are using it on. There may be validation or other code behind the scenes that is keeping it from working. Keys will work consistently and we've switched to always using that for text fields.
03-21-2017 12:25 AM
It's true, simple things are sometimes more complicated than one would think.
In my own SetText function, I do the following:
determine a second control to activate
set Focus to field
set the .wText property
set Focus to 2nd control
check for msgboxes
check .wText of field
until field has correct .wText or msgbox shown or nr. of iterations too large
The SetFocus function also deals with overlapping Windows.
03-21-2017 08:29 AM
In the application we're testing, we can't use "SetText" for login processes to our application. There is security stuff on the login page that does not allow for a forced "set" of the text property of the controls. We have to use the "Keys" method.
Please try replacing "SetText" with Keys and go from there.
03-21-2017 09:12 AM
Wow, now we've given the same answer three times in row, shall we try for four?
LOL... It's been a weird day for me otherwise I would have caught that duplication.. at least we're consistent, yes?