mikej411
10 years agoOccasional Contributor
How to verify whether a blinking cursor is currently inside of a text box
I am trying to verify that the text box gets the focus (the blinking cursor gets placed inside of it) after a certain action. I tried to use the Focused property, but it does not seem to work, or the object just doesnt have this property to begin with. Here is the code:
mainWindow = Aliases.iexplore.IESA; saveWindow = mainWindow.Find("ObjectIdentifier", "MainContent_saveFilterSetDialog_saveDialog", 50, true); saveWindowNameTextBox = saveWindow.Find("ObjectIdentifier", "*MainContent_*_sfsName", 25, true); if(saveWindowNameTextBox.Focused == true) Log.Message("The blinking cursor is inside of the name text box") else Log.Error("The blinking cursor is not inside of the name text box")
The logging window says "Waiting for Focused", then it fails and the log says "Unable to find the object with the specified properties"
Is there another way to accomplish this?
Got it. Everything works now, thank you!
var actualFocusedElement = Sys.Browser().Page("*BC/Report*").contentDocument.activeElement.id if(aqString.Contains(actualElement, "saveDialog_tmpl_sfsName", 0, true)) Log.Message("The blinking cursor is inside of the name text box") else Log.Error("The blinking cursor is not inside of the name text box")
I used the actual focused element's ObjectIdentifier (ID) and compared it against the expected ID, utilizing the activeElement jScript function.