lundi 15 mai 2017

Gmail's new Login Screen and Next button

I was writing my coded UI test in visual studio 2013(update 5) & my browser is ie 11.In one of my specific coded UI method, it redirects from my application(http://ift.tt/2pCu1LT) to gmail( www.gmail.com ) where it try to find some specific mails ,delete them and logout.I need to do this for two times one by one (for two gmail account) .it was working great with old gmail screen.But after when the new gmail login screen comes in , it fails at a specific point.

After redirecting to gmail(from my application), it put the email in the email textbox.then click next button.After clicking this next button it just showing my applications login screen instead of the password textbox of gmail. it is not happening all the time but it happens few time and my test method fails.I don't know why it is happening.But One thing i am confused about is my application & gmail, both have password textbox with the same name 'password'(one has uppercase), but their parent element are different.

After redirecting to gmail, my code(signin code) is given bellow

public void SignIn(string gUserName, string gPassword)
    {

BrowserWindow.ClearCookies();
BrowserWindow.ClearCookies();

var browser = new BrowserWindow();

    //browser.TechnologyName = "MSAA";

    browser.SearchProperties.Add(UITestControl.PropertyNames.ClassName, "IEFrame", UITestControl.PropertyNames.ControlType, "Window", UITestControl.PropertyNames.Name, "Gmail");

            var divContainer = new HtmlDiv(browser);
            divContainer.SearchProperties[HtmlDiv.PropertyNames.Id] = "view_container";
            divContainer.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);

            //Put email
            var emailEdit = new HtmlEdit(divContainer);
            emailEdit.SearchProperties["Id"] = "identifierId";
            emailEdit.SearchProperties["Name"] = "identifier";
            emailEdit.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);
            if(emailEdit.TryFind() && emailEdit.WaitForControlReady())
            {
                if(!emailEdit.ReadOnly)
                {
                    emailEdit.Text = gUserName;
                }
            }

            var divNext = new HtmlDiv(divContainer);
            divNext.SearchProperties["Id"] = "identifierNext";
            if(divNext.TryFind() && divNext.WaitForControlReady())
            {
                var divNextInner = new HtmlSpan(divNext);
                divNextInner.SearchProperties[HtmlSpan.PropertyNames.InnerText] = "Next";
                divNextInner.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);

                Mouse.Click(divNextInner);
                Playback.Wait(5000);
            }
            //Put password
            var passEdit = new HtmlEdit(divContainer);
            passEdit.SearchProperties["Name"] = "password";
            passEdit.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);

            if(passEdit.TryFind() && passEdit.WaitForControlReady())
            {
                passEdit.Text = gPassword;

                var divSignIn = new HtmlDiv(divContainer);
                divSignIn.SearchProperties["Id"] = "passwordNext";
                if(divSignIn.TryFind() && divSignIn.WaitForControlReady())
                {
                    var divNextInner1 = new HtmlSpan(divSignIn);
                  divNextInner1.SearchProperties[HtmlSpan.PropertyNames.InnerText] = "Next";
                    divNextInner1.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);

                    Mouse.Click(divNextInner1);
                    Playback.Wait(3000);
                }
            }

}

Can you please help me, it is urgent.

Best Regards

sabbir

Aucun commentaire:

Enregistrer un commentaire