could not successfully authenticate using White

Jan 25, 2012 at 4:01 AM
Edited Jan 25, 2012 at 4:02 AM

Hello all

             I am trying to automate a installation of a software through white. In that installation screen I have two textboxes for user name and password input now when I run the automation script of white in c# and enter User name and password and click validate button the validation fails. But for same User name and password when i enter it manually it runs successfully. I double checked the user name and password which goes through script and which I entered manually.

Please Help Thanks in advanced.

Jan 25, 2012 at 7:25 AM

Hi

have you debugged it? Is the automatically entered text complete entered?

Can you show the code you use?

 

Throndorin

Jan 25, 2012 at 12:03 PM
Edited Jan 25, 2012 at 12:10 PM

Hey Throndorin many thanks for showing interese in my question

I have debugged it

following is my code.

Window _white = new Window();

_white.Get<TextBox>(SearchCriteria.Indexed(2)).Enter("sa");//User Name
 _white.Get<TextBox>(SearchCriteria.Indexed(3)).Enter("sapx");//Password

_white.Get<TextBox>(SearchCriteria.Indexed(4)).Enter("sa");//User Name
_white.Get<TextBox>(SearchCriteria.Indexed(5)).Enter("sapx");/Password

 _white.Get<Button>(SearchCriteria.ByText("Next")).Click();///Unable to Authenticate comes here after the next button click

One thing to tell is I couldnt handle the waits in White. (ie. I couldnt understand how to implement them) so I Implemented my own method ,following  is my code to handle the waits.

public void clickNext()

{

SearchCriteria searchCriteriaObject = SearchCriteria.ByText("Next");

 _white = GetWhiteWindow("Window Title", searchCriteriaObject);

_white.Get<Button>(SearchCriteria.ByText("Next")).Click()

}

public static Window GetWhiteWindow(string title, SearchCriteria searchCriteria)
        {
            try
            {
                IUIItem UI = null;
                Window window;
                int counter = 1000;

                do
                {
                    window = null;

                    _application.WaitWhileBusy(); Thread.Sleep(2500);

                    window = _application.GetWindow(title);
                    UI = window.Get(searchCriteria);

                    if (UI != null)
                    {
                        if (UI.Enabled)
                        {
                            return window;
                        }
                        else
                        {
                            UI = null;
                        }
                    }                   
                    counter--;

                } while (UI == null && counter > 0);

                return null;
            }
            catch (Exception Ex)
            {
                return null;
            }
        }

 

please help

Jan 25, 2012 at 12:26 PM

Hi

From code it seems to be OK

try the following:

TextBox userName = _white.Get<TextBox>(SearchCriteria.Indexed(2));
userName.Enter("sa");//User Name
TextBox password =  _white.Get<TextBox>(SearchCriteria.Indexed(3));
password.Enter("sapx");//Password

TextBox userName2 = _white.Get<TextBox>(SearchCriteria.Indexed(4));
userName2.Enter("sa");//User Name
TextBox password2 = _white.Get<TextBox>(SearchCriteria.Indexed(5));
password2.Enter("sapx");/Password

Trace.WriteLine("\""+userName.Text+"\"");
Trace.WriteLine("\""+password.Text+"\"");
Trace.WriteLine("\""+userName2.Text+"\"");
Trace.WriteLine("\""+password2.Text+"\"");


_white.Get<Button>(SearchCriteria.ByText("Next")).Click();

Trace should show that the strings are correct entered!

you can also try userName.BulkText ="sa"; instead of Enter() Operation

Throndorin

Jan 25, 2012 at 4:22 PM

 

Throndorin, I can't be wrong but it's impossible to get Text out of password TextBox. You will get "[Operation is not valid due to the current state of the object.]"

Jan 27, 2012 at 7:02 AM

@niosocket thanks for advice

 

in fact you need a way to clarify that the entered texts are correct. In my opinion the values are not correct entered in this case

 

Throndorin