Why cypress loads login page again instead of home page? - cypress

I wrote a cypress script to log in to the application ( enter the user id, password and click the log-in button), and expecting to load the home page. Cypress enters the user id, password and clicks the button but, loads the login page again instead of the home page.
Below is my script to login:
`
cy.visit('https://digitalxq1.com/sis/basic?accountNumber=123456');
cy.enterText(txtUserID, userid);
cy.enterText(txtPwd, 121212);
cy.clickElement(btnPwd);
Has anyone faced a similar issue? And, Does anyone knows the solution? Please assist.

The nature of the application forced me to log in first without account no- " cy.visit('https://digitalxq1.com/sis/basic'" and reload the app with account number after that - "cy.visit('https://digitalxq1.com/sis/basic?accountNumber=123456')" ).
I made mistake of doing the refresh immediately after clicking on login button as below:
cy.visit('https://digitalxq1.com/sis/basic');
cy.enterText(txtUserID, userid);
cy.enterText(txtPwd, 121212);
cy.clickElement(btnPwd);
cy.visit('https://digitalxq1.com/sis/basic?accountNumber=123456'
Somehow cypress unable to respond to the refresh and loaded the login page again. As a solution, I did validate whether the app is loaded or not after clicking login button. Then proceeded with refresh as below:
cy.visit('https://digitalxq1.com/sis/basic');
cy.enterText(txtUserID, userid);
cy.enterText(txtPwd, 121212);
cy.clickElement(btnPwd);
cy.get(#testElement). should('have.length',2);
cy.visit('https://digitalxq1.com/sis/basic?accountNumber=123456'
This approach resolved my issue.

Try this cy.reload(); this will work.
If you want to reload the page with cache then try this cy.reload(true)

Related

Cypress does not show the final page after running cy.origin

The test's domain is "exams.com/courses/XXXX"(xxxx is the course's #). After clicking the "buy course" button, the domain will be "payment.com".We filled in the payment information, and click the "pay" button, the webpage should be "exams.com/purchased_courses/XXXX".
Now I used cy.origin:
it("buy courses",()=>{
.........//click the "buy course" button
cy.origin("payment.com",()=>{
.........//fill in the payment information
cy.get('.submitButton-IconContainer').click()
//click the "pay" button
})
}
)
Issue is: when running the testing, the webpage "exams.com/purchased_courses/XXXX" slashed a second, and finally, the webpage stays in "exams.com/courses/XXXX".
Question:How can I let the testing shows "exams.com/purchased_courses/XXXX"? Thank you!
env: cypress 10.X.X
typescripe
node.js 18.8.0

How to make "stay logged in" work in Selenium webdriver?

I am working in a website like https://jira.atlassian.com/ using firefox, after clicking the "log in" on the top right corner, i am taken to the next login page, where on the right of "log in" button, there is this "stay logged in" checkbox, already checked.
I tested it manually. It seems that after i log in successfully, if i do not exit the page by log out, but simply close the page, the next time i enter https://jira.atlassian.com/, i am already logged in. Ok, make sense.
However, if testing such using selenium webdriver, log in, close page, open page again, the above does not happen.
My question is what is the mechanism for this "stay logged in", is it the same as "remember me"? and how do i make it happen when using selenium webdriver?
Up till now my understanding is:
this happens because of cookie
cookie is stored in firefox profile
selenium start with a default profile that does not include cookie, and can not store cookie during the test
Is there a relatively standard solution for this problem, in java preferably?
Thanks,
As far as I am aware, each instance of loading a FF with Selenium opens a stripped browser with no history/cookies/extensions etc. It's as if you have just download FF for the first time and its a fresh copy. I am not sure how to solve this issue. Maybe if you keep the session open by not closing the browser down but log out manually and not closing down the browser. Or open a new tab and opening the same address.
you can try to store the cookies and apply them to your new firefox instance
get the cookies using:
Set<Cookie> cookies = driver.manage().getCookies();
and than apply them to your new webdriver instance:
for(Cookie cook : cookies) {
driver.manage().addCookie(cook);
}

How to restart Vaadin session?

After logout I need to invalidate session and start a new immediately. I used the function
VaadinSession.getCurrent().getSession().invalidate();
After several seconds a red box "Session expired" appears. User must click on it or press F5. How to avoid it and to display new session page immediately?
In javascript is it easy:
document.location='/';
How to do the same in Vaadin? The behavior should be the same as by first visit the page after restarting explorer.
In my project I use this:
Page.getCurrent().setLocation( "/" );
VaadinSession.getCurrent().close();

Wicket - Internet Explorer double submit

I have a big problem with Internet Explorer 7 and 8.
SITUATION:
I have a FORM that build a Medical Prescription. When I hit the save button, the script saves the DomainObject on DB and set a boolean property (of panel where the form is added) called "saved" to true and a byte[] property called PDF with bytestream.
On RenderHead of Panel, I read this boolean and, if is true, I force the trigger of a hidden button with this code:
String js = "$('#" + printPDF.getMarkupId() + "').click();";
response.renderOnDomReadyJavaScript(js);
The button executes this code:
ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(new ByteArrayResourceStream(pdf, "application/pdf"));
handler.setFileName("foo.pdf");
RequestCycle.get().scheduleRequestHandlerAfterCurrent(handler);
This code work perfecly on FF and Chrome. The Browser download windows appears and the user can save the PDF on HD.
Unfortunally, Internet Explorer has that damn security behavior that is triggered when a site require something to download. That warning require a user validation. A yellow Bar appear and the user is force to hit "Download".
screenshot http://imageshack.us/a/img198/1438/securityg.jpg
When I hit Download File, the form is submitted again with the exact state I had when I hit save the first time. So no previous INSERT on DB is already committed; The Session is resetted to the previous state etc...
The result is a double INSERT on DB of the Domain Ojbect.
Any clue to resolve this?
The problem is that you click download link programaticly instead to redirect browser to an URL or open an URL by JS window.open(url). Click a link looks like an unwanted operation that is sometimes restricted by browser.

Blank login page on CSWinPhone7SimpleApp

I'm trying to use the Facebook C# SDK from Codeplex on my WP7 app. I managed to build & run the application by manually adding Facebook.dll and Microsoft.Contracts.dll. But I only see a blank login(?) page :
The code enters FacebookLoginBrowser_Navigated, after loading this url :
http://www.facebook.com/dialog/oauth/?response_type=token&display=touch&scope=user_about_me,read_notifications&client_id=119779898114420&redirect_uri=http://www.facebook.com/connect/login_success.html
but the URL seems to have been redirected to this one :
http://m.facebook.com/login.php?app_id=119779898114420&cancel=http://www.facebook.com/connect/login_success.html?error_reason=user_denied&error=access_denied&error_description=The+user+denied+your+request.&fbconnect=1&next=http://www.facebook.com/connect/uiserver.php?method=permissions.request&app_id=119779898114420&display=touch&redirect_uri=http%253A%252F%252Fwww.facebook.com%252Fconnect%252Flogin_success.html&response_type=token&fbconnect=1&perms=user_about_me%252Cread_notifications&from_login=1&rcount=1
The important part is "User denied access", which I didn't, since I don't see anything except a blank page.
Thanks in advance !
edit: pasting the first url into an iPhone simulator Safari.app, I see the Facebook login screen, then after login, I see the grant permission screen...
your browser is not script enabled, try to set the flag at true :

Resources