New page (tab) not persisting in test suite

Hello all,
I need some help with using a new page (tab) in the test suite.
Opening a browser with a new page (via New Browser and New Page keywords) works okay. The same page can be used in all test cases in the same suite file.

However, the issue happens with a new page, which is only available in the test case where it was opened. In the subsequent test cases, switching to the page is not possible, since I get an error:

ValueError: No page with requested id 'page=6392e37d-795e-4c7b-bd32-357011cc0c82' found.

I am storing page ids in a dictionary, which is set as a suite variable. The page id of original page seems to be stored and accessed successfully, since navigating to it works okay.

It appears to me that after the test case where new page is opened finished, the new page gets closed and only original page remains open.

Has anyone encountered this issue before or understands how pages functions to help me out on this?

Thank you and best regards!
A

@Aero10 Take a look at https://marketsquare.github.io/robotframework-browser/Browser.html#Automatic%20page%20and%20context%20closing.
Maybe a silly question, but why do you want to share a page between test cases?
In my opinion test cases should be independent of each other.

2 Likes

Thank you @falcon030
I have read the Automatic page and context closing section of the documentation. Indeed I have not set any setting for auto closing (auto/test/suite). However, despite this, the browser and original page is used continuously in the test suite. So I cannot figure, why the same does not apply for a newly opened page.

Maybe a silly question, but why do you want to share a page between test cases?
In my opinion test cases should be independent of each other.

This is a very valid point and something I have considered as well. I was on the fence about it. It just so happens that there is a very long test case, which is divided into steps. And the steps in itself are a sort of test case of their own.
I might indeed change the implementation at some point. But for now, I would like to try creating a suite with multiple test cases, sharing the same browser, context and pages.

Thank you,
A

@Aero10 Do you use suite setup to create a context and the first page? Also instead of creating a new page after you have already created one, maybe you can use Go to ?

Yes, new browser and new context are created in one of the suite setup keywords.

“Go to” argument is page url, not page id, isn’t it? For switching between pages I use “Switch page” keyword. And I can confirm switching between pages/tabs worked well, until I broke the long test case down into separate ones.

@Aero10 That is because the default “Automatic page and context closing” takes place on “test” level, except when you create the context and page in a suite setup, these are closed in the teardown.
So when you create a new page in a new test case, this page is closed when the test case ends.

2 Likes

Many thanks, @falcon030 , your last post explained the situation exactly and solved the tabs issue I was facing. It makes absolute sense and makes me wonder how I could miss that myself.

Well, I suppose that is what learning is about. And this community is doing a wonderful job sharing the knowledge. Thank you once again!

Best wishes

1 Like