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

assembly for Test Studio

3 Answers 21 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 12 Feb 2014, 06:00 PM
Hello,

I am writing a assembly for Test Studio

I have tried to specify the base class that my class inherits as being BaseTest and BaseWebAiiTest

I have a Manager instance that is initialized to Manager.Current.

I can reference the myManager.ActiveBrowser... just fine.

But when I try to create a wait using:

HtmlInputCheckBox _checkbox = myManager.ActiveBrowser.Find.ByExpression<HtmlInputCheckBox>(DomString);

HtmlWait waitObj = _checkbox.Wait;

           
_checkbox.Wait.ForVisible(5000);

I get the following error when the coded step executes:

System.NullReferenceException: Object reference not set to an instance of an object.

The line that causes this exception is

HtmlWait waitObj = _checkbox.Wait;

I cannot find what object that needs to be referenced to instantiate this wait object.

Thanks 


3 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 17 Feb 2014, 06:47 PM
Hello Joe,

My #1 suspicion is that "myManager.ActiveBrowser.Find.ByExpression<HtmlInputCheckBox>(DomString);" did not actually find anything. When .Find does not find the target element what you get back is a NULL. The (rather obviously) "_checkbox.Wait;" will throw a null reference exception. You can verify the Find succeeded by testing for null like this:

Assert.IsNotNull(_checkbox);

The assert will fail and cause the test to abort of _checkbox is null i.e. the Find failed.

As a side note, given this code:
HtmlInputCheckBox _checkbox = myManager.ActiveBrowser.Find.ByExpression<HtmlInputCheckBox>(DomString);
HtmlWait waitObj = _checkbox.Wait;
_checkbox.Wait.ForVisible(5000);

The HtmlWait waitObj = _checkbox.Wait; code is unnecessary as you're not using waitObj later.

Regards,
Cody
Telerik
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Joe
Top achievements
Rank 1
answered on 18 Feb 2014, 04:38 PM
Thanks Cody,

That was the problem

Joe
0
Cody
Telerik team
answered on 18 Feb 2014, 05:01 PM
Hello Joe,

Good to know! Thank you for the update.

Regards,
Cody
Telerik
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Joe
Top achievements
Rank 1
Answers by
Cody
Telerik team
Joe
Top achievements
Rank 1
Share this question
or