This is a migrated thread and some comments may be shown as answers.

Password TextBox Problem

9 Answers 229 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pouya
Top achievements
Rank 1
Pouya asked on 01 Dec 2011, 08:25 PM
Using the AspNet browser, I am able to grab both the UserName and Password TextBoxes. I insert my username and attempt to insert my password and click the Login button. This fails.
I dump the source and only see that the Username Textbox is populated.
The UserName and Password textbox are located within an ASP:Login control.
Any suggestions?
This is the first step before I test the rest of my application and need a way to log into the system.
Thank you.

9 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 06 Dec 2011, 12:42 AM
Hi Pouya,

I suspect you are identifying the password field as a regular input text field, and not an input password field. This code worked for me:

[TestMethod]
public void AspLoginControl()
{
 Manager.LaunchNewBrowser();
 
 Find.ById<HtmlTable>("PlaceHolderForContents_Login1").ScrollToVisible();
 Find.ById<HtmlInputText>("PlaceHolderForContents_Login1_UserName").Text = "test";
 Find.ById<HtmlInputPassword>("PlaceHolderForContents_Login1_Password").Text = "tester";
     
}
 

Regards,
Anthony
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Pouya
Top achievements
Rank 1
answered on 06 Dec 2011, 03:16 PM
In my test, after I get the password textbox element and attempt to set a password, this occurs:

DialogPlayback: DialogMonitor.Start() : Beginning monitoring for dialogs from the set {}.
UIAutomation: AutomationExtensions.AddAutomationEventHandler() : Added a(n) WindowPatternIdentifiers.WindowOpenedProperty handler on element System.Windows.Automation.AutomationElement scope Descendants.
Framework: Manager.get_ActiveBrowser() : The current ActiveBrowser is either invisible or disconnected.
Framework: Manager.AddNewBrowser() : Added client ID "Client_2a892b5e-f61c-492e-b9e0-d153648fcbf5" (now there is/are 1 total).
Framework: BrowserProvisioner.EndService() : Connecting to the provisioning pipe "Pipe.ArtOfTest.WebAii.BrowserProvisioner" in order to unblock and eventually terminate it...
Framework: BrowserProvisioner.EndService() : Provisioning pipe connected.
Framework: BrowserProvisioner.ServiceThread() : A new client has connected to the provisioning pipe but this will be treated as a termination cue.
Framework: BrowserProvisioner.EndService() : Provisioning thread terminated.
DialogPlayback: DialogMonitor.Stop() : Dialog monitoring is being halted.

Demonstrate performing automation actions against Asp.Net in Proc Host.: ArtOfTest.WebAii.Exceptions.UnsupportedBrowserOperationException : Browser type 'AspNetHost' does not support the following operation: 'InvokeScript'

at ArtOfTest.WebAii.BrowserSpecialized.AspNetHost.AspNetHostActions.InvokeScript(String script)
at ArtOfTest.WebAii.ObjectModel.Element.SetValue(String propertyName, T value)
at ArtOfTest.WebAii.Controls.HtmlControls.HtmlInputControl.set_Value(String value)
at ArtOfTest.WebAii.Controls.HtmlControls.HtmlInputPassword.set_Text(String value)
at QuickStarts_NUnit_CS.AspNetInProcHost2.AspNetInProcTesting() in AspNetInProcHost2.cs: line 161

0
Anthony
Telerik team
answered on 06 Dec 2011, 11:46 PM
Hello Pouya,

Is your test against a publicly accessible site? Please provide the full code; we'd like to see the issue first-hand. 

Does the sample test I provided work for you?

All the best,
Anthony
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Pouya
Top achievements
Rank 1
answered on 13 Dec 2011, 09:21 PM
I have attached a zip with the Login.aspx page and the test.
There are a couple issues:
1) Line 42:  Manager.LaunchNewBrowser();
  -- This actually launches a Internet Explorer browser.
2) Line 50: Find.ById<HtmlTable>("Content_Login1").ScrollToVisible();
  -- Exception: Browser type 'AspNetHost' does not support the following operation: 'ExecuteCommand'

If I comment out line 50.

3) Line 58: _userpasswordTextbox.Text = "Password!123";
-- Exception: Browser type 'AspNetHost' does not support the following operation: 'InvokeScript' I need to be able to set the password and click the login button in order to test any of my later pages.
0
Anthony
Telerik team
answered on 13 Dec 2011, 11:19 PM
Hi Pouya,

Unfortunately I am unable to load the page or run the test with just the two files you provided. I'll need a complete, running project to load it and test it locally just as you are.

The sample test I included is intended to be run against a public site by launching a new instance of Internet Explorer. Getting started with Telerik Testing Framework in this context is explained here

Regards,
Anthony
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Pouya
Top achievements
Rank 1
answered on 15 Dec 2011, 07:33 PM
First, update your hosts file (c:\Windows\System32\drivers\etc\hosts) and add the following line (this will make your development environment similar to ours):
127.0.0.1      localhost localhost.telerik.com

Couple of things I have noticed:
If this call:
Settings settings = GetSettings(); 
Retrieves the settings from my config file, then setting the DefaultBrowser:
settings.Web.DefaultBrowser = BrowserType.AspNetHost;
Will not work and on
Manager.LaunchNewBrowser();
a visible instance of IE is launched.
If the call
Settings settings = GetSettings(); 
Retrieves the default settings, then all the subsequent calls leading up to 
Manager.LaunchNewBrowser();
Work as expected and an invisible AspNetHost browser is launched.

I have attached a solution that highlights the problems I am having.

Thank you.
0
Anthony
Telerik team
answered on 16 Dec 2011, 08:59 PM
Hi Pouya,

Thank you for the project. I was able to reproduce the error.

First, the ScrollToVisible() will not work in your AspNetHostBrowser test because no browser window is launched to be scrolled. I included that step in my original sample code for an ActiveBrowser test against a live web page.

Second, the error received from the _userpasswordTextbox.Text line is a bug. I filed a report for it and you can find the PITS Issue here: Public URL.

In the meantime, replace that line with the following code:

//_userpasswordTextbox.Text = "Password!123";
Actions.SetText(_userpasswordTextbox.BaseElement, "Password!123");
 

Greetings,
Anthony
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Pouya
Top achievements
Rank 1
answered on 21 Dec 2011, 09:39 PM
Anthony,
I'm glad that I helped identify an issue. But, at this point, your suggestion is still not inserting a password into that text box.
Do you have any other suggestions?

Thank you. 
0
Anthony
Telerik team
answered on 21 Dec 2011, 11:20 PM
Hi Pouya,

That is puzzling. As you can see in the following screen recording, that line works for me in your project:

http://screencast.com/t/s8zlC5Ra

What error are you receiving? What line in the code does it reference?

Unfortunately the bug I filed has not been updated, so I cannot provide an ETA on when the fix will be implemented. 

Does this need to be an AspNetHostBrowser test? You can adapt the code into an ActiveBrowser test that launches a browser window and interacts against the live web page. You should then be able to input text into the password field with the original line of code.

Kind regards,
Anthony
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Pouya
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Pouya
Top achievements
Rank 1
Share this question
or