Currently using Protractor 5.1.0 with cucumber-protractor-framework with Javascript.
In using the following Scenario Outline in the Feature file:
Feature: As an online customer
I should be able to validate the Benefits Page and links on it
Background:
Given I am on the "Benefits Page"
@regression @fixup
Scenario Outline: validation of the MyPage links
When I click on the "<link>" link
Then a new tab should be opened
Then I should be directed to the "<URL>" in new window
Examples:
|link |URL |
|Benefit (PDF) |/guide-to-benefit.pdf |
|Pro Benefit (PDF) |/professional-benefit.pdf |
|Signature Benefit (PDF) |/signature-guide-to-benefits-revised.pdf |
|Business Benefit (PDF) |/business-benefits.pdf |
And the Page file follows:
var Benefits_Guide_Page = function (PageUrl) {
this.visit = function (PageUrl) {
browser.manage().deleteAllCookies();
browser.get(PageUrl);
};
this.get_element = function (element_name) {
switch (element_name) {
//Links Navigates to different window
case "Benefit (PDF)":
case "Pro Benefit (PDF)":
case "Signature Benefit (PDF)":
case "Business Benefit (PDF)":
return element(by.linkText(element_name));
break;
... // continue element checks
Each scenario opens the tab, switches to the new tab, validates the URL, closes the new tab, switches to the original tab, and reloads the original page, starting the next example.
I think there is something of an answer in this Android Q&A, but I'm not sure it's the same problem.
Basically, I don't need the page to reload with each example. It's wasteful and time consuming in context of the larger test.
I have other scenarios where I'm checking links loading in the same window. I just need to go "back" and check the next link or same page anchor, not load the page again.
Any tips?
sleepon each run as they were not using Promises correctly to wait. Reduced it to 30 secs. I think I can shave off more if I can solve the reload problem. - javafueledhrefof theatag and validate it. 2. put this in a unit test, if it's really for validating the url's this could be done much faster with for example karma jasmine 3. don't validate this, it's basic html work. The first 2 suggested options are depending on how you handle the link. If there is a lot of Angular code that handles the click, processes stuff and then opens a tab, then you are right, if not (option 3), don't waste your time in automating these kind of tests in the GUI. - wswebcreationvisit(url)function, but I'm not sure what I need to change and the documentation is sparse. - javafueled