How can I run test scenario in chrome using browser cache in karate? - karate

I am testing a scenario in which I have to run chrome with cache so how can I do that as by default it launches browser without any cache.

This is not a normal requirement, but we have an option to set the userDataDir, here below is a screenshot from the documentation:
So if you know the path of a directory that exists, you can pass that. That said, maybe the correct testing strategy is to make a call 2 times and ensure that the second call is being cached. But some investigation may be required.

Related

ModHeader blocks the real service when not in use

I am using ModHeader when I test with mock but when I pause it and I am connected with a real service then it seems that I cannot use real test data to test and I get always error pages. If I go on incognito mode and use the same test data (real service behind) then all good, I don´t have any problem. If my session is expired and I continue testing without being in a incognito mode then I have again no problem. It is somehow a session saved somewhere and sees that extension as active although is not. This issue appeared after a couple of updates of the browsers (Chrome and Firefox). I use the extension on Chrome and Firefox equally. Anyone having something similar?

How to to run all the scenarios of one feature file in single browser instance

How to to run all the scenarios of one feature file in single browser instance. #After and#Before hooks instantiate after each scenario, Can't we execute them before all scenarios once and after all scenarios?
I assume when you say "single browser instance", you are talking about not restarting the browser between tests.
You need to add
serenity.restart.browser.for.each = feature
in your serenity.properties.

Testcafe which remote browser did my test run in?

I use a custom browser provider - saucelabs - I'd like my custom reporter to know in which remote browser it ran so I can properly correlate the saucelabs video with a failed test.
This obviously is only an issue with concurrency > 1 :)
If a test fails which remote browser was it run in???
thanks!!
Mark
The reportTestDone method of a reporter plugin is called after a test is done in all browsers. If testRunInfo.errs array is empty, it means that the test passed in all browsers. If it is non-empty, every item has a userAgent property, telling in which browser the error occurred.
So, if you need a list of browsers in which the test fails, you could use something like this: _.chain(testRunInfo.errs).map('userAgent').uniq().value().
I didn't find this in the official documentation, though.

Take over browser from selenium session

I'm not sure if there is a term for what I'm trying to do. I currently have a test suite using codeception for a php application. What I would like to do is be able to either of the following:
watch the browser automation in an actual browser
take over the browser at a specific point ( Sort of like a hand over from the script to the browser to allow me to continue to run a session )
Is this possible? If so what is it called in the selenium documentation
a) Selenium runs the actual browser and you can see what it is doing unless you configured Selenium to run some headless browser (but I don't know anything about headless browsers supported by Selenium);
b) Use Codeception's pauseExecution method to stop execution at specific point.
Documentation:
Pauses test execution in debug mode. To proceed test press “ENTER” in
console.
This method is useful while writing tests, since it allows you to
inspect the current page in the middle of a test case.

Nightwatch.js - Use the same browser session

We would love to adopt Nightwatch.js for testing on browsers, but we're stuck on one major caveat: at the time of this writing, Nightwatchjs does not support running different tests using the same browser session. In short, it means that:
Creating the browser session is handled by the Nightwatch module from lib/index.js, in the startSession function;
Killing the browser would correspond to the delete command place in the Selenium action queue in the terminate function of that module;
A new Nightwatch client is created at every test run, which happens every time we load a different test file;
According to this source, it is possible to reuse the current browser session in Selenium, instead of opening a new window.
Has anyone managed to fix this problem in Nightwatch?
Here's the feature request on Github, which was requested on Mar 31, 2014 and is still open.
Another approach would be to circumvent the problem altogether by getting Nightwatch to merge all different files into one Test Suite, but that seems to be harder to solve than the problem with sessions...
Nightwatch now has support for resuing browser sessions. You can simply use the flag --reuse-browser to reuse sessions while running your nightwatch tests.