0

My system under test is a website, that dynamically creates pages from a config file and an index page with clickable icons to these pages. So far I could not find a way to iterate through the icons on the index page and test all the linked pages.

    it('lets us test all the pages', () =>
    actorCalled('Jasmine').attemptsTo(
        Loop.over(EntryPage.SynthLinks).to(
            Ensure.that(Loop.item<ElementFinder>(), isClickable()),
            Click.on(Loop.item<ElementFinder>()),
            Wait.for(Duration.ofSeconds(10)),
            Log.the(Website.title()),
            //Navigate.back(),
        ),
    ));

This loop works in so far, that it shows me all the pages in Chrome, but the logged website title is always the one from the index page, so I cannot do any testing on the clicked pages.(The commented Navigate.back()also breaks the test.) I tried to read the url of the clicked pages out of Loop.item<ElementFinder>(), so I could use Navigate.To()instead, but I could not find any method for this.

tommiport5
  • 43
  • 9

1 Answers1

0

Ok, I found it out. The culprit was the website under test, it did not use a href for the link, but a bit of js code:

[...]
var Subwindows = [];
function openSub(name) {
    var neighbour = window.open(name);
    Subwindows.push(neighbour);
}
[...]
<a onclick="openSub('../SynthPage.html?Mdl=access+virus+b')"><img src="../images/virus.jpg" class="icon" alt="access virus b"></a>

The idea is to remember the opened pages and close them, when done. So the good Chrome executed the js faithfully and showed me the opened page (in a separate tab), but the focus of the test was still the original page. I will have to figure out, how to test that one ||:-)

tommiport5
  • 43
  • 9
  • Serenity/JS now provides new interactions to [`Switch`](https://serenity-js.org/modules/protractor/class/src/screenplay/interactions/Switch.ts~Switch.html) to another frame window and to [`Close`](https://serenity-js.org/modules/protractor/class/src/screenplay/interactions/Close.ts~Close.html) tabs/windows, which you might find useful in this scenario. – Jan Molak Mar 15 '21 at 02:09
  • Thank You, I found this already in the docu. This solved my problem. – tommiport5 Mar 16 '21 at 08:17