Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "SetProperty of "Text" is not supported on control type: Window" when trying to set text in textBox #41

Closed
arushisingh90 opened this issue Oct 2, 2015 · 4 comments

Comments

@arushisingh90
Copy link

Getting "SetProperty of "Text" is not supported on control type: Window" when trying to set text in textbox.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CUITe.SearchConfigurations;
using Microsoft.VisualStudio.TestTools.UITesting;
using CUITe.Controls.HtmlControls;

namespace ABCSmokeTestCuite.ObjectRepository
{
    public class ABCLoginPage : BrowserWindowUnderTest
    {
        public ABCLoginPage()
            : base("ABC - Log-in Page")
        {
        }

        public ABCLoginPage(string windowTitle)
            : base(windowTitle)
        {

        }

        public HtmlEdit txtTemp1 = new HtmlEdit(By.SearchProperties("Id=ctl00_ContentPlaceHolder1_loginABC_UserName"));        
        public HtmlPassword txtTemp2 = new HtmlPassword(By.SearchProperties("Id=ctl00_ContentPlaceHolder1_loginABC_Password"));
        public HtmlInputButton btnLogIn = new HtmlInputButton(By.SearchProperties("Id=ctl00_ContentPlaceHolder1_loginABC_LoginButton"));
    }
}


public void Login(string url, string username, string password)
{

       MBESLoginPage loginPage = BrowserWindowUnderTest.GetBrowserWindow<ABCLoginPage>("ABC - Log-in Page");

       loginPage.txtTemp1.Text = username;
       loginPage.txtTemp2.Text = password;
       loginPage.btnLogIn.Click();
}
@icnocop
Copy link
Owner

icnocop commented Oct 2, 2015

Please try using properties instead of fields:

        public HtmlEdit txtTemp1
        {
            get
            {
                return this.Find<HtmlEdit>(By.SearchProperties("Id=ctl00_ContentPlaceHolder1_loginABC_UserName"));
            }
        }

        public HtmlPassword txtTemp2
        {
            get
            {
                return this.Find<HtmlPassword>(By.SearchProperties("Id=ctl00_ContentPlaceHolder1_loginABC_Password"));
            }
        }

        public HtmlInputButton btnLogIn
        {
            get
            {
                return this.Find<HtmlInputButton>(By.SearchProperties("Id=ctl00_ContentPlaceHolder1_loginABC_LoginButton"));
            }
        }

@arushisingh90
Copy link
Author

That worked. Thank you.
This code was generated by recorder so I was wondering why didn't the recorder generate property instead of fields.

@FantasticFiasco
Copy link
Collaborator

This is a bug introduced by me. I'd be happy to take a look at it during this weekend and fix the issue.

@arushisingh90
Copy link
Author

That would be great. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants