Playwright MSTest injected Page object gets reset on every TestMethod - playwright

I started using Playwright in MSTest and I have my test class implement the base PageTest class.
One thing I am wondering: Is the instance of the injected Page object gets reset on every TestMethod?
I tried to log the Page.URL on every TestMethod and the first one got it correctly (set via the overridden ContextOptions) but the succeeding logs shows null.
And when I took a screenshot inside the TestMethods, the first one shows my full page but the next ones are empty.
Is this expected behavior? Does it mean I have to visit and login again on the site I am testing on every TestMethods that I have?
I am coming from Cypress and each test function inside the spec file shares the same context of the page. So I am wondering if I setup something wrong or is this expected behavior.

Related

Fitnesse Scenario library local to Suite level not oncluded

I have my test cases in Fitnesse suite. I have created a Scenario Library local to the suite. But inside the test page its not getting loaded.
here is my Structure
My Tests
Contents
Test1
Test2
Suite1
ScenarioLibrary
Test1
So under Test1, I cannot see the contents of the Scenario Library. here is the screen shot of what I see,
As you can see, its picking up my library name but its just displayed as plain text not with and Include Page and expand option.
Whats going wrong here?
I had a similar problem, and in that case one of my parent page names was not a valid 'wiki word'. When I renamed that page all went well.
Any chance Step02IPhoneSuite causes a similar problem? I don't recall the definition of wiki word of the top of my head, but I notice 2 capitals next to each other in that name. If you rename that page to Step02iPhone, does that help?

Robot framework: Storing faker-generated data for the duration of the test suite

I have created a suffix for any test data I use in my test cases, for instance when adding an account you must enter a name for it, I use the static text "test" and then add the suffix to the end of this, this is what I do for all fields.
However, I need to check that this data has been saved correctly and is displayed correctly during these test cases so I need to somehow make Robot Framework remember this suffix I've generated. So far in my test cases I've just been using set variable after generating the data with faker, but obviously this is contained within the keyword, how could I make it so that this generated data is accessible for the duration of my testing session (until all tests, in the folder are finished)?
My code at the minute:
*** Test Cases ***
Valid Login
Open Browser To Login Page
${num}= Random Int
${suffix}= set variable ${num}
Input Text username ${suffix}
To reiterate, I then want to check this ${suffix} value in another test case
Thanks in advance!
Edit:
Test suite file
*** Test Cases ***
Valid Login
Open Browser To Login Page
Fill field a11y-username ${MYNUM}
Resource file
*** Variables ***
${MYNUM}
*** Keywords ***
Suite Setup
${MYNUM}= Random Int
Set Suite Variable ${MYNUM}
There is the "set suite variable" keyword for that. I would create a Suite Setup (in a init.txt file if you have several files in your folders for your different tests) that creates this ${suffix} and make it available for all tests in the suite:
${num}= Random Int
${SUFFIX}= set suite variable ${num}
note: I use capital letters to show that the variable has a bigger scope than just local

how to debug this lithium request?

I am trying to work on whats wrong with my lithium current setup. I have installed the Xdebug and verified that remote host can establish the connection as requested.
http://myinstance.com/test/lithium/tests/cases/analysis/logger/adapter/CacheTest?filters[]=lithium\test\filter\Coverage
Please note in fresh installation in local environment , "Coverage" Filter is working as expected.
I added some test code inside the "apply" function in coverage.php but it is not even called !!!! Can some have experience in debugging the above URL ?
I am not able to understand why coverage filter is not called up and executed ...Any hints are highly appreciated !
The filters in the query string are added to the options in lithium\test\Controller::__invoke() and then passed into the test Report object created by the test Dispatcher. The Report object finds the test filter class and then runs the applyFilter() method for that test filter as can be seen in lines 140 to 143 of the current code. So those lines would be another place to debug. Those should wrap the run() method of your tests with this filter code inside the apply() method that uses xdebug_get_code_coverage() and related functions. You said you added test code in the apply method and it isn't called. I'm not sure what the issue is. Are you sure you are pointing to the right server and code location? It is possible to run tests from the command line. Maybe you should try that. See code comments in lithium\console\command\Test or run li3 test --help for info on how to use the command-line test runner.
I can confirm on nginx I also have /test/lithium/tests/cases/analysis/logger/adapter/CacheTest?filters[]=lithium\x5Ctest\x5Cfilter\x5CCoverage in my access log. The \x5C is expected url encoding of the backslash character.

Grails breaks after telling me that files exist in the views folder when they actually do not?

When I try to scaffold new controller and views for some domain class, Grails keeps telling me that there exists files in grails-app/views/domainName/{create.gsp, edit.gsp, list.gsp, show.gsp}.
However I have repeatedly deleted the whole domainName dir from the views location many times.
What is Grails referring to? is this related to caching somehow?
Even if I ignore this abnormality and tell grails to overwrite the files even though they dont exist, when i lunch the application, navigate to that controller and click create new domainItem - the browser with think for a minute after which Grails spits the following exception:
Error executing script RunApp: GC overhead limit exceeded
2011-11-02 10:22:50,484 [ContainerBackgroundProcessor[StandardEngine[Tomcat]]] ERROR core.ContainerBase - Sanitizing stacktrace:
- Exception invoking periodic operation:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:116)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:722)
The app works fine with any other domain class.
Things I have tried:
1. delete the problematic domain along with the controller and views, delete the unit test, delete the generated class files. basically eradicate any known-to-me trace of that domain class
2. run 'clean'
3. make a new domain with the same name
4. scaffold the views and controller for it again (at which point grails ask me if I want to override the views?!)
5. restart STS
6. restart computer
so the problem is in this line:
time(range:0L..86400000L) //24h in milliseconds
which I still dont understand why. the variable time is of type long
The following two variations also result in memory overflow:
time(range:0..86400000L)
time(range:0..86400000)

How can I configure Fitnesse to automatically add the Test property to all pages ending in "Tests"

I its default configuration fitnesse automatically adds the Test property to all pages ending in "Test".
However, in the project I'm working I have to add the Test property to all pages ending in "Tests". Unfortunately, renaming all pages so that they end in "Test" is not a option for me.
Since the 2008xxxx versions of Fitnesse any page that starts or ends with Test is automatically set to be a test page and any page starting or ending in Suite is set to be a suite. This is done on the creation of the page and probably will not work by just renaming the page.
Note: If you have a large number of test pages to retrofit, you could use wingrep/grepwin (or some other tool that can do large scale file search and replace, I personally use grepwin) and manipulate the properties.xml by inserting
<Test>true</Test>
Set the pages test property in one of the following ways:
1. Visit the page, click properties, select the test checkbox.
2. Vist the page with ?properties, select the test checkbox
3. Modify the properties.xml file associated with the page to include the tag inside the block.
Method 3 would be the easiest to automate for a large number of files.
Could probably do this with a grep file utility to do a mass search and replace.
Or a script (powershell) or program to read the files and add this tag if needed.

Resources