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

Unable to find Html elements

6 Answers 102 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
gmendez
Top achievements
Rank 1
gmendez asked on 05 Jun 2015, 11:51 PM

Hello, I'm struggling with a problem that doesn't make sense to me. 

I'm writing some tests (I'm totally new to the testing framework), the first of which consists on login to the site.

So I'm doing this:

 myManager.ActiveBrowser.NavigateTo(site.LoginURL);

 myManager.ActiveBrowser.WaitUntilReady();

 Thread.Sleep(5000);

 //Find username control
 HtmlInputText usernameControl = myManager.ActiveBrowser.Find.ById<HtmlInputText>("email");
 usernameControl.MouseClick();
 myManager.Desktop.KeyBoard.TypeText(site.DefaultUser.Username);

//Find password control

 HtmlInputPassword passwordControl = myManager.ActiveBrowser.Find.ById<HtmlInputPassword>("password");

 passwordControl.MouseClick();
 myManager.Desktop.KeyBoard.TypeText(site.DefaultUser.Password);

 Element loginBtn = myManager.ActiveBrowser.Find.ById("loginBtn"); 
 myManager.ActiveBrowser.Actions.Click(loginBtn);

 

 I had to use html elements for the imput boxes because the site is made using ember.js and looks like it requires "real typing".

The problem is that if I run this against a local testing site it works perfectly. However if I try to run it against a site (an identical copy) on a remote server, the framework can't find the controls and I get a null reference exception because the object "usernameControl" is null.

I can warranty that the site hosted on the remote server contains those controls, and that's why this doesn't make sense to me. 

Am I missing something? Any help will be appreciated.

Thanks in advance,

 

Gonzalo

6 Answers, 1 is accepted

Sort by
0
gmendez
Top achievements
Rank 1
answered on 07 Jun 2015, 11:16 PM

By the way, forgot to tell that I reviewed all the settings specified for IE. I'm running IE 11 on Windows 8.1. 

The solution was compiled against .NET 4.5.2.

Also tryed to use Find.ByName<TControl> but still doesn't work.

Thanks.

0
Ivaylo
Telerik team
answered on 10 Jun 2015, 01:24 PM
Hello Gonzalo,

Due to the nature of the problem we will need the test you are executing with access to the tested application in order to determine what is causing the problem. However only from the code and the description provided we are not able to investigate any further.

Regards,
Ivaylo
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
gmendez
Top achievements
Rank 1
answered on 10 Jun 2015, 05:40 PM

Hello Ivaylo,

 Attached you fill find Example.zip. It's a simple console application that fails on finding the textboxes.

Off course it's trying to access the real url. 

As I said, I have an identical copy of this site in my computer, which I can run my tests against without problems.

Cheers!

 Gonzalo

 

 

0
Accepted
Ivaylo
Telerik team
answered on 15 Jun 2015, 01:24 PM
Hello Gonzalo,

Thank you for providing me with the repro, I was able to reproduce the behavior easily and easily to fix it, just added the following line:

myManager.ActiveBrowser.RefreshDomTree();

and the test never failed afterwards.

Here is a sample video demonstration(no audio).

Hope this should work for you as well.


Regards,
Ivaylo
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
gmendez
Top achievements
Rank 1
answered on 15 Jun 2015, 07:21 PM

Hi Ivailo,

Thanks a lot for your reply.

Worked perfectly!

 Cheers!

 Gonzalo

0
Ivaylo
Telerik team
answered on 18 Jun 2015, 11:08 AM
Hello,

You are most welcome.

Regards,
Ivaylo
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
gmendez
Top achievements
Rank 1
Answers by
gmendez
Top achievements
Rank 1
Ivaylo
Telerik team
Share this question
or