I'm manually setting the cookie during the test run as the userRole is not working for me in my local environment as the client sets the cookie and due to some reasons TestCafe clears it out.
When my first test is ran it kicks out and I set the cookie before the second test. I can see the cookie exists but as I'm already in the login page I need to use t.navigateTo(URL) to login to the homepage. When I use it t.navigateTo(URL) clears out the cookie and I keep in the login page instead of the homepage.
If I manually enter the URL of my homepage while the test is stopped at a breakpoint I'm successfully able to go to my home page and my test pass if the debug is resumed from this point onwards.
I was hopeful that the t.navigateTo(URL) would be just doing the redirect to URL but it seems with the redirect it is clearing out cookies as well. Any fix for this?
I actually figured out. By running the tests with flag --disable-page-caching it worked.
Related
I am getting the login session through some API. I do the following -
Navigate to the www.example.com
Set cookies through Selenium WebDriver.
Navigate the browser to www.example.com\some-other-path
And voila, the cookies don't get apply as I get the login page again.
However, If I reload the page after doing #2, and then navigate away, the cookies seems to be applied correctly. Any idea guys what could be the issue?
Here is my code -
driver.get("http://www.example.com");
driver.manage().deleteAllCookies();
driver.manage().addCookie(c1); //I have the cookie object
//driver.navigate().refresh(); If I uncomment it, works good
driver.navigate().to("http://www.example.com/some-other-url");
You could go through the following post which talks about using the same cookies
https://sqa.stackexchange.com/questions/15594/selenium-how-to-access-the-same-session-in-a-new-window
Hope this helps
I have included a form which takes user's input and sets a cookie with setcookie php function while processing the form.
This works in one server, but doesn't work on other.
The server in which the cookies isn't working shows some blank httponly cookies in client's browser.
I don't know how to troubleshoot this..I can see form values are successfully being submitted in POST, but I don't know what's happening when it runs setcookie.
And yes, I am setting the cookie in before html and in headers.
My php is custom installation and is of 5.4.45 and httpd version is 2.2.
This was set in my httpd.conf file causing cookie to not work:
Header set Set-Cookie HttpOnly;Secure
I don't know the consequences of disabling it. But I have disabled it anyway temporarily, until I know what they are for.
I want to use FirebaseUI in redirect mode, as opposed to the current popup mode I'm using. But I don't want to have a separate dedicated login URL, instead I want the user to be able to log in from any URL (using a custom dialog as the UI container for FirebaseUI).
The problem I run into is that when starting the login process, I show the dialog and the user selects their auth provider, gets redirected to the auth website, but then they are redirected back to the original URL on my website.
Now the UI container dialog is not displayed and firebaseUI.start() doesn't get called because the webpage doesn't know that the user is in the process of logging in. The result is that nothing happens - the user is halfway through the login process.
Is there any way I can specify a URL for the first redirect? I'm not talking about the final signInSuccessUrl config parameter, but something similar for the first redirect back to my website?
That way I'd be able to send the original URL that started the login process along with a flag or something that tells the webpage that the user is in the middle of a login flow so that it can display the login process UI container and call firebaseUI.start() to perform the last redirect.
You can start FirebaseUI from any URL but the underlying signInWithRedirect always return to the same URL. Calling start on redirect will complete the sign in. If you have some condition, where you don't always display the sign in UI, you can use some flag pendingRedirect which you save in sessionStorage and check before rendering the UI to complete the sign-in on return. You would clear that after rendering.
I have a Rails 3 app running on Heroku. For authentication I use devise. The session data are stored in a cookie.
Now when I use Firefox I can see the cookie - I use a Firefox plugin to see it; when I use IE I cannot see it: there is not cookie file getting set and when I use the developer console to view the cookies I get nothing. The web app is working fine in IE so somehow the cookie gets sent to the server.
What is going on? How can I see the session cookie in IE?
Thanks for any help.
-Matteo
Does your URL contain an underscore? Internet Explorer does not like underscores in the URL when handling cookies.
I have a password-protected Apache web directory I'm testing. When I first access the directory, it requires that I login in. However, on subsequent tries it let's me right in, even after I clear my browser cache- how do I get it to force a login again?
The browser stores the credentials and sends them along with every request - usually, for the duration of the current session.
Closing the browser and re-opening it makes it usually forget the credentials.
Forcing the browser to forget credentials (i.e. logging out) is tricky. See HTTP authentication logout via PHP for some approaches.
Easiest way I've found:
Using Firefox 4 on Mac,
Go to 'Tools' > 'Clear Recent History...' > 'Active Logins'
Refresh the page (You don't have to close the window)