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

[Solved] Convert to code - Object reference not set to an instance of an object

7 Answers 37 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Hans Keller
Top achievements
Rank 1
Hans Keller asked on 16 Oct 2009, 05:02 PM

Hello,

I 'm using the trial version of Telerik WebUI Test Studio to investigate whether it will be appropriate for our company to purchase, to aid the testing of our product.

The Test Studio seems ideal, but I am having a few problems. I am trying to create a procedure, but have got stuck on one part....

Part of the procedure involves clicking a button on our website that produces a pop-up window, in which a check box needs to be ticked and another button clicked to close the pop-up. this works fine when running the script back from the test explorer before converting to code, but as soon as it is converted to code the error 'Object reference not set to an instance of an object' occurs whether you run from the code itself or the test explorer. 

this is the code created

[CodedStep(@"Check 'input_CheckBox__ChkItemSelected' to be 'True'")]

public void WebAiiTest1_CodedStep()

{

// Check 'input_CheckBox__ChkItemSelected' to be 'True'

HtmlInputCheckBox input_CheckBox__ChkItemSelected = Pages.Childcare_Enquiry.Frame_ctl00_ctl00_ctl00_MainContent_PopupOpenerHis.input_CheckBox__ChkItemSelected;

input_CheckBox__ChkItemSelected.Wait.ForExists(10000);

input_CheckBox__ChkItemSelected.Check(true, true);

}

I look forward to any help you can provide...

Cheers,
 
Hans

 

7 Answers, 1 is accepted

Sort by
0
Missing User
answered on 16 Oct 2009, 07:47 PM
Hi Hans,

Thank you for your evaluation of WebUI Test Studio, we hope you find it useful for your testing needs. I couldn't replicate the problem you are seeing, so I'd like to ask a few questions about your pages.

From the code you posted, it looks like the check box is in a frame within the popup. Did your test run reliably several times before converting to code? Is the popup window still launched during test execution? If this is still the case, is there any dynamic attribute generation for the frame? Or is there any dynamic element generation within popup window page or in the source of the frame?

I'm asking because WebUI uses find parameters for the elements on the page at the time of recording for test playback. You can change the find params to something that would be more relaible for each popup launch and here is a link that describes this.

This problem maybe somewhat difficult to troubleshoot on this end without being able to look at the pages or html code. Would it be possible for us to either access your site or view the page code?

Sincerely,
Nelson Sin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Hans Keller
Top achievements
Rank 1
answered on 19 Oct 2009, 01:45 PM

Hello Nelson,

Thanks for you swift response,

I thought you might need more information as i think it might be specific to our site.
Firstly answering you questions

  • The test ran reliably several times before converting to code.
  • The popup window still launches during the test execution.
  • There is a dynamic element in the webpage the popup is triggered from, but not in the popup itself.

I have attempted changing the parameters, but without success. I guess it might be easier for you to help us, if I provide you with the exact example; this however is a little difficult as the information used on our website is sensitive. Would it be possible to send an email (opposed to publishing the details on you website) with details of how to access to a test site where I can set up a user for you and explain in detail what I’m trying to do?

Kind regards,

Hans

0
Konstantin Petkov
Telerik team
answered on 19 Oct 2009, 01:56 PM
Hello Hans,

Please feel free to submit a private support ticket and send the necessary details there. We can continue troubleshooting the problem using the ticket.

Sincerely yours,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Hans Keller
Top achievements
Rank 1
answered on 19 Oct 2009, 03:48 PM

Thank you Konstantin,

I will submit a ticket as soon as I have all the information. I’m just waiting on our DBAs to update the test database (likely to be tomorrow at the earliest) so all constraints will be the same for you.

Just in case you can solve the problem without the exact details but with some more helpful info from me. I have been doing some more investigation and the popup box in question uses iFrame. Each time the test runs the frame details change (see 2 examples below). I guess this is why it can not find the check box as its looking for the previous frame that doesn't exist anymore. I can see that you can change the parameters of the search for the check box within the frame (Elements Explorer), but can’t see how you can do the same for the frame, could you please point me in the right direction. If this doesn't make sense, don't worry we can wait until our team has the test site set up so I can give you an example....

[Frame:name=ctl00_ctl00_ctl00_MainContent_PopupOpenerHistoryableList,src=../Master/Telerik.Web.UI.DialogHandler.aspx?DialogName=HistoryableList&Skin=Default&Title=Please select an item from the list&doid=e15c5e77-1bee-474c-a000-ec08b8e0b944&dpptn=&dp=YHFlMzs5L1lRHRhySTV%2BM1cfUHN5ZXBCT1VfFFE2FBMuSmJDUzBiVTxgBmZqOmRZfwU7CQdhfghhc2kRYi1eGFVbaktkZm9SUXBcG3RVCRNcAXkkYQ4jXS1yAlBvY1czBAw3YX88QVt%2BUmIwbEZQYUAAbGt5UnFpUjR3UDVydl1gDw1Z]

[Frame:name=ctl00_ctl00_ctl00_MainContent_PopupOpenerHistoryableList,src=../Master/Telerik.Web.UI.DialogHandler.aspx?DialogName=HistoryableList&Skin=Default&Title=Please select an item from the list&doid=d46db13a-6a0c-4d39-8c5a-24189bb9bf55&dpptn=&dp=YHFlMzs5L1lRHRhySTV%2BM1cfUHN5ZXBCT1VfFFE2FBMuSmJDUzBiVTxgBmZqOmRZfwU7CQdhfghhc2kRYi1eGFVbaktkZm9SUXBcG3RVCRNcAXkkYQ4jXS1yAlBvY1czBAw3YX88QVt%2BUmIwbEZQYUAAbGt5UnFpUjR3UDVydl1gDw1Z]

Thanks again for the help

Hans

0
Missing User
answered on 19 Oct 2009, 07:26 PM
Hi again Hans,

Thanks for the info, it seems like something is happening on code generation that is causing this problem since it worked reliably before code conversion. 

It looks like the source of the frame is constant, so we may be able to use that to find the frame.
So finding the frame might look something like Browser b = ActiveBrowser.Frames.BySrc("~Telerik.Web.UI.DialogHandler.aspx");

Then you could do HtmlInputCheckBox input_CheckBox__ChkItemSelected = b.Find.By...<HtmlInputCheckBox >("FindParam");

You can find the FindParam WebUI uses by right clicking on
input_CheckBox__ChkItemSelected in the Elements Explorer Window. So, Find will be something like b.Find.ByName or b.Find.ById based on how WebUI finds the element according to attributes, XPath, TextContent, etc.

You can try this if you'd like right now, or we can try this and some other workarounds if you still wish us to look at the page on this end.

Regards,
Nelson
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Hans Keller
Top achievements
Rank 1
answered on 21 Oct 2009, 04:16 PM
Thanks again Nelson,

I gave it a go, but sorry i still couldn't solve the problem. I have sent a Private Support Ticket with all the info.

Thanks for all the help.
0
Missing User
answered on 21 Oct 2009, 08:39 PM
Hi again Hans,

Thanks for posting all the info and access to your site in the other ticket. If it's ok, I'll reply to the issue on that ticket.

Thanks again,
Nelson
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Hans Keller
Top achievements
Rank 1
Answers by
Missing User
Hans Keller
Top achievements
Rank 1
Konstantin Petkov
Telerik team
Share this question
or