How can I access a new window when test is running using cypress - cypress

I want to visit an url perform some operations then open different url in different tab/window and perform some action in new tab and come back to the previous tab/window and so on. Is this possible in cypress?
Please suggest some solution if possible.

Cypress does not and will not support handling more than one tab/browser, for further read and recipes see: https://docs.cypress.io/guides/references/trade-offs.html#Multiple-tabs

I see two solutions:
Use api request for the operations needed for the external url
Divide the test in different cases
2.1. In before/beforeEach section make preparations needed
2.2. It case for first part in your project
2.3. It case for the different url
2.4. It case for the second part needed in your project
If have some repetitive data that needs to be reused - you can declare it as a variable ouside of the "describe" scope with usual JS code.

Related

Vaadin UI between sessions

When I am creating a new session (or try to access from an other computer) in Vaadin Flow I get this error:
Can't move a node from one state tree to another
From this link, I read something about UI and getUIId().
However, I don't understand how I should change my application in order to fix the error.
As Denis mentioned in the forum post you linked, wrong scope sounds like the most likely culprit. In other words, you are trying to use the exact same component instance in two different UIs, when both UIs should have their own instance. It's not possible to use the same instance in two places at the same time.
You can find the documentation for Vaadin Spring scopes here: https://vaadin.com/docs/latest/flow/integrations/spring/scopes
One possible cause of errors such as that is that if you're storing a Component in a static variable. You shouldn't do that - a Component instance can only belong to a single UI. A single UI in turn (in practice) means a single browser tab.

Reuse Cucumber steps across features files in Cypress

Is there a way to reuse steps in our features from "other" step files?
I.e. I have a project with login page, and topbar that I want to test after login:
Got LoginPage.feature and LoginPage.js step file, everything works fine, all tests run correctly.
I would like reuse steps “Given user open TestPage login page” and “When user login using valid credentials” from LoginPage.js in TopBarCmp.feature:
But it always ends with error:
Long time ago I used Specflow(Cucumber for .net) and it was normal to ruse steps with same singatures across all features.
What is correct way of handling that kind of situations, where we would like to use some part that was already automated?
Looks like you can put them either on cypress/integration/common or in cypress/support/step_definitions and they will be available to share across features
this article explains it better https://www.linkedin.com/pulse/part-2-hands-on-test-automation-project-cypress-reis-fernandes

cy.visit() failed because while attempting to visit a second unique domain/location/url in a single test case

I need to navigate two different urls in a single Test but when am navigating second one , it giving me error
1.FirstUrl- "https://app.ca-test.com/Public/Login?ReturnUrl=%2F"
2.SecondUrl -"https://www.mailinator.com/"(location and origin is change)
"cy.visit() failed because you are attempting to visit a URL that is of a different origin."
I used cy.request() also but didn't work
so how can we do this??
But i have to navigate two urls in single test, and can not divide test case. This is my TestCase
Cypress is preventing going cross origin since always forever. This was kinda covered in this question, but only kinda.
To sum up:
Different domains in one test are not officially supported, at least not yet. There is a whole section regarding this in the Cypress documentation
There is a feature request on their board to support more than
one, but I don't see it being implemented anytime soon, there are some workarounds posted in that ticket, maybe one of them will work for you.
You could disable chrome cross-origin security by adding chromeWebSecurity: false to the cypress.json config file
If you want to use Mailinator to check/send emails, why do you have to visit the site? Just use their API and cy.request()
Never link your test environment directly here.

How to create a Checkpoint in UFT

Strange enough that I have to ask such a simple question.
I started automating with UFT and I suppose the correct way to check if for instance my login has worked is to add a checkpoint on the next page.
But how do I do that?
All info I get from google is on how to add an already existing checkpoint to may page. But I don't have any.
Here is how I go about automating:
I add manually the relevant objects to the object repository
I create parameters for my action
I create the code that does the steps on the page
one action per page seems to be fine for me
But in the Object Repository of UFT 14.53, there is no button to add a Checkpoint.
A workaround for me would be to just add another Object and check it's existence and forget about checkpoints. Until I hopefully get an answer here, I will try to do just that.
In UFT there are typically two ways to verify that things are working as expected.
Flow (implicit) - In order to verify that progress in the application is successful (e.g. login) one usually just keeps working with the app, assuming that if the previous step failed, the objects needed for the next steps won't exist and the test will fail due to ObjectNotFound errors
State (explicit) - In order to see that objects have a specific state, checkpoints are usually used. Checkpoints are typically added during a record session, I'm not sure if there's a way to add them directly to the repository. An alternative to checkpoints, which works better with keyword driven testing (no recording), is to use the built in CheckProperty method.

Bootstrap ui-router states programmatically

I'm working with angular 1.
I want to load some data from server before ui-router bootstrapping all the states.
Is it possible to do so?
I would say that in this Question: AngularJS - UI-router - How to configure dynamic views and mostly in this answer you can get the answer.
The point is to use a feature of UrlRouterProvider - deferIntercept()
The deferIntercept(defer)
Disables (or enables) deferring location change interception.
If you wish to customize the behavior of syncing the URL (for example,
if you wish to defer a transition but maintain the current URL), call
this method at configuration time. Then, at run time, call
$urlRouter.listen() after you have configured your own
$locationChangeSuccess event handler.
Full description including working example is here

Resources