Testcodeunits: Strange behavior when executing an action through invoke

ImperatorMing
Member Posts: 13
As you can already see from the title, I noticed a strange behavior when executing page actions on a testpage through invoke(). I am working on BC16.
I created a "Sales Header" in my codeunit and added a few "Sales line"'s. Then I wanted to load the page by a TestPage object and click the action "Post." Here is the code:
I now expect that the execution of the test informs me that I have not handled the UI window for selecting the posting type, as it would appear if I used the web client normally:

Instead of that, it informs me that i am leaving the Page without releasing:

That would correspond to this Message in the web client when leaving an order:

Does anyone know whats wrong here? Why am i leaving the Page in my test and not start the posting?
Thanks for your time!
I created a "Sales Header" in my codeunit and added a few "Sales line"'s. Then I wanted to load the page by a TestPage object and click the action "Post." Here is the code:
codeunit 60001 "Test Codeunit" { Subtype = Test; trigger OnRun() begin end; [Test] procedure TestOne() var SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line"; SalesOrder: TestPage "Sales Order"; begin // Create a Sales Order with "External Document No", and set the "Due Date" to the past (-10) SalesHeader.Init(); SalesHeader.Validate("Document Type", SalesHeader."Document Type"::Order); SalesHeader.Validate("Sell-to Customer No.", '01121212'); SalesHeader.Validate("Due Date", Workdate() - 10); SalesHeader.Validate("External Document No.", '123'); SalesHeader.Insert(true); // Create 2 Corresponding random Sales Lines CreateSalesLine(SalesHeader, SalesLine.Type::Item); CreateSalesLine(SalesHeader, SalesLine.Type::Item); // Goto to the Corresponding Sales Order Page and post that stuff. SalesOrder.OpenEdit(); SalesOrder.GoToKey(SalesHeader."Document Type", SalesHeader."No."); SalesOrder.Post.Invoke(); end; }
I now expect that the execution of the test informs me that I have not handled the UI window for selecting the posting type, as it would appear if I used the web client normally:

Instead of that, it informs me that i am leaving the Page without releasing:

That would correspond to this Message in the web client when leaving an order:

Does anyone know whats wrong here? Why am i leaving the Page in my test and not start the posting?
Thanks for your time!
0
Best Answer
-
Good morning,
I'm also not sure, why you get this error message.
But I would try to change the code like that:SalesOrder.Release.Invoke(); SalesOrder.Post.Invoke();
And see if there is a difference.5
Answers
-
Good morning,
I'm also not sure, why you get this error message.
But I would try to change the code like that:SalesOrder.Release.Invoke(); SalesOrder.Post.Invoke();
And see if there is a difference.5 -
Thanks, i already did this and it works for me.
But I am still amazed. As a user, I can also post without realsing before. Why do I have to do this explicitly in my test? Seems strange.
Nerver the less, thanks for help.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions