I was just trying to perform a task after i stop the test run in QTP.
The actual scenario is like this:
I want to login into some site(project internal), perform some task and when i stop the test run, it should automatically logoff from the site.
There is a logoff button too on the web page.
But the challenge is that we have to logoff after we stop the test not before stopping the test run.
kindly help me out, i tried a lot but i am not able to do that.
Thanks in advance.
I'm not sure I understand why you would want to log off after the test stops, why not have the final step of the test log off?
Also from your question it sounds like you're talking about manually stopping the test
when i stop the test run, it should automatically logoff from the site
This seems to be an un-interesting case, if you're manually stopping the test then you can manually log-off and for automatic test runs (which is the point of automatic testing) behave as is required (log off at the last step etc.)
QTP does support closing a browser after the test run (when the test is closed) this is done from the Record and Run Settings dialog.
All that being said here's a hacky way to get what (I think) you're looking for, have this as the last step of your test:
Browser("Br").Navigate "javascript:setTimeout('document.getElementById(""logout"").click();', 5000); void(0)"
What this does is tell the browser to call a specific function after 5 seconds (5000 milliseconds) (using a bookmaklet), the code being called after 5 seconds clicks on the log off button (you'll have to use the correct id or otherwise locate the button of course).
As I said I'm not sure I understood your problem so I don't know how helpful this will be.
Related
I need to start the server inside the tests. I have read the advice at https://docs.cypress.io/guides/references/best-practices#Web-Servers, and I still need to start the server inside the tests (and possibly restart it mid-test). If I try to do that, I get the error "Cypress could not verify that this server is running:" and as far as I can see it never even tries to run the beforeEach that would start it. Is it possible to bypass that behaviour?
As far as I'm aware that's not exactly configurable, but you can leave out the baseUrl entirely. If Cypress doesn't know where your app is running, it won't do any pre-test polling to find out if it's up.
However note this also means you have to use the full URL in cy.visit and, because the main window is loaded on a random port on localhost (per the docs):
...Cypress then switches to the url of the main window to the url
specified in your visit. This can result in a 'flash' or 'reload' when
your tests first start.
Is the silentRenewHeartBeatCheck supposed to run every 3-4 seconds? I just want to know if I configured something wrong or not. I don't even know where to look to check for something that would configure this. If it is doing what it is supposed to be doing I won't worry about it.
In just a few minutes I've got 150 of these in chrome dev tools console:
silentRenewHeartBeatCheck
silentRenewRunning: true
idToken: true
_userData.value: true
Early on in my log I also get the below error as well but no idea what is causing it except I'm assuming it has something to do with the silent renew iframe running, but maybe not:
Active resource loading counts reached to a per-frame limit while the tab is in background. Network requests will be delayed until a previous loading finishes, or the tab is foregrounded. See https://www.chromestatus.com/feature/5527160148197376 for more details
You can check the source code here: https://github.com/damienbod/angular-auth-oidc-client/blob/master/src/services/oidc.security.service.ts.
Unfortunately, it's hard-coded to run every three seconds and there is no configuration option.
As far as the silentRenewHeartBeatCheck message issue:
In your OpenIDImplicitFlowConfiguration make sure log_console_debug_active is set to false. That will stop the silentRenewHeartBeatCheck messages in your console.
If a user was to restart the browser, via the restart methods (Shift + F2 > "restart" > enter) Or other methods, is it possible to listen for this and execute code before shutting down then starting up again?
I was thinking of registering obvserver for quit-application and if data parameter was retstart the execute some code, but my worry is, firefox is shutdown before code gets to execute, can someone please verify this thought of mine is false or true. and if true (it cant execute code) then can you please provide an alternative way which allows for code execution.
thanks
firefox is shutdown before code gets to execute, can someone please
verify this thought of mine is false or true. and if true (it cant
execute code) then can you please provide an alternative way which
allows for code execution.
If your code is synchronous then it will block shutdown, if it's asynchronous then it may not finish.
The Application Shutdown observer notification list on MDN also provides more notifications you can use besides quit-application in the order that they are called. You can see there are a couple that come before quit-application.
I am running delayed_job for a few background services, all of which, until recently, run in isolation e.g. send an email, write a report etc.
I now have a need for one delayed_job, as its last step, to lodge another delayed_job.
delay.deploy() - when delayed_job runs this, it triggers a deploy action, the last step of which is to ...
delay.update_status() - when delayed_job runs this job, it will check the status of the deploy we started. If the deploy is still progressing, we call delay.update_status() again, if the deploy has stopped we write the final deploy status to a db record.
Step 1 works fine - after 5 seconds, delayed_job fires up the deploy, which starts the deployment, and then calls delay.update_status().
But here,
instead of update_status() starting up in 5 seconds, delayed_job goes into a busy loop, firing of a bunch of update_status calls, and looping really hard without pause.
I can see the logs filling up with all these calls, the server slows down, until the end-condition for update_status is reached (deploy has eventually succeeded or failed), and things get quiet again.
Am I using Delayed_Job::delay() incorrectly, am I missing a basic tenent of this use-case ?
OK it turns out this is "expected behaviour" - if you are already in the code running for a delayed_job, and you call .delay() again, without specifying a delay, it will run immediately. You need to add the parameter run_at:
delay(queue: :deploy, run_at: 10.seconds.from_now).check_status
See the discussion in google groups
Normally, billings should execute in the background on a scheduled date (I haven't figured out how to do that yet, but that's another topic).
But occasionally, the user may wish to execute a billing manually. Once clicked, I would like to be sure the operation runs to completion regardless of what happens on the user side (e.g. closes browser, machine dies, network goes down, whatever).
I'm pretty sure db.SaveChanges() wraps its DB operations in a transaction, so from a server perspective I believe the whole thing will either finish or fail, with no partial effect.
But what about all the work between the POST and the db.SaveChanges()? Is there a way to be sure the user can't inadvertently or intentionally stop that from completing?
I guess a corollary to this question is what happens to a running Asynchronous Controller or a running Task or Thread if the user disconnects?
My previous project was actually doing a billing system in MVC. I distinctly remember testing out what would happen if I used Task and then quickly exited the site. It did all of the calculations just fine, ran a stored procedure in SQL Server, and sent me an e-mail when it was done.
So, to answer your question: If you wrap the operations in a Task it should finish anyways with no problems.