Recently, I have been delving into writing e2e tests in Protractor using page objects with JavaScript/Node.js. After reading numerous Stack Overflow posts and Julie's pages, as well as studying ProtractorPageObjects, I've come across an issue.
All the tables within the application follow the same structure, with the only difference being the attribute data-row-type, which can have one of 10 possible values like 'job', 'node', 'rack', etc...
I could simply pass the string to a method and switch within the method to construct the correct selector. However, based on comments from ProTractorPageObjects, I am hesitant to write the code in that manner. Is there a way to avoid passing in the string and create such a method without doing so?
In chapter 5 of ProTractorPageObjects, the columns.js file discourages using a pattern where a string is passed in to determine what is being sought.
For instance:
<div id="ee54a74e-17b8-4380-bbd8-2a5087bad7c9" class="tableRow escale-table-row-selected" data-row-type="ipAddress" data-qa-row-number="1">
<div class="tableCell">
<span class=""></span> ips-172-20-143-20-21
</div>
<div class="tableCell">
<span class=""></span> UP
</div>
<div class="tableCell">
<span class=""></span> Yes
</div>
...
Another Table:
<div id="6f529383-c0f3-49b7-9ccb-c8db2b0c75a9" class="tableRow escale-table-row-selected" data-row-type="fileSystem" data-qa-row-number="0">
<div class="tableCell">
<span class=""></span> card-view<div><span class="fa fa-square success fileSystemIndicator"></span><span id="6f529383-c0f3-49b7-9ccb-c8db2b0c75a9-share" class="fa fa-square fileSystemIndicator success"></span><span id="6f529383-c0f3-49b7-9ccb-c8db2b0c75a9-accessRule" class="fa fa-square fileSystemIndicator success"></span></div>
</div>
<div class="tableCell">
<span class=""></span> UP
</div>
<div class="tableCell">
<span class=""></span> Yes
</div>
......