If you have been using Ranorex Webtestit, you may have noticed that all Page Object files and Test files contain a comment in the first line, saying
// Ranorex Webtestit Page Object File
// Ranorex Webtestit Test File
If you have been feeling adventurous, you may have been tempted to remove this line. In this case, you’ve probably noticed an “out-of-sync” warning in the Page Object overview for Page Objects, and other strange side effects, when doing it for Test files.
Why does Ranorex Webtestit need this header?
Ranorex Webtestit uses this first line as a fast method to recognize Page Object files and Test files when opening a project, in order to provide you with a set of features to interact with your Page Objects and Tests (the Page Object overview and Element panels, various context-specific snippets, keyboard shortcuts and more).
In the past, we did not properly communicate the importance of these headers, which may have caused some frustration to some Ranorex Webtestit users. However, since Version 0.20.0, Ranorex Webtestit will scan your Page Object and Test files for these header comments, and warn you when you are trying to save a file with missing or malformed header comments.
What can I do when my Page Object or Test file has a missing or malformed header comment?
In the code editor, access the Quick Fix menu via the light bulb icon or the
Ctrl+. shortcut, and select
Insert or fix file header. The header comment should appear in the first line of your file, and the warnings should disappear.
If you can not see the Quick Fix menu, it is possible that Ranorex Webtestit already did not recognize your file correctly when you opened the project. In this case, you can try to add the headers manually (see above), and then re-open your project.
The header line in a Page Object or Test file is necessary for us to provide certain features, but if you accidentally remove it from its spot on the top, Webtestit will let you know, and help you restore it.