Issue in SetText() method
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Issue in SetText() method
I wrote python script for a simple test scenario. Have to enter username and password in the edit box. I used the below code
username.SetText("admin")
password.Keys("abcdef")
save_button.Click()
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
repeat
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wow, now we've given the same answer three times in row, shall we try for four?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Marsha_R wrote:
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? 🙂
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
