PDA

View Full Version : Is it possible to allow Sencha Test to send previously set browser cookies?



jflowers45
15 Nov 2017, 10:34 AM
The behavior I've observed when using in-browser scenarios suggests that a browser opened with Sencha Test to a given domain doesn't "inherit" cookies that have been set in other active instances of the browser. Is this an accurate assessment, and if so, is it possible to change this?

Case in point: If I open "https://www.sencha.com/forum/" in a new tab right now by hand, it says "Welcome jflowers45". If I launch a new in-browser scenario at the same url, which opens a new tab in chrome, it doesn't recognize me.

The reason I'm asking is that I'm operating in an authentication scenario similar to the one described here, where users authenticate using a card reader:
https://www.sencha.com/forum/showthread.php?371098-Tests-that-login-with-client-certificate

I'm aware that testing scenarios that require authentication of any sort are typically handled by creating a WebDriver scenario that enters a username and password and navigates to the next page, but that's not currently an option for me as they require all authentication to be done using smart cards.

The client is open to a solution whereby the user has to log in with their card reader before beginning the tests, but I'm not sure if it's feasible.

Any guidance is appreciated. Thank you!

-Joe

daniel.gallo
15 Nov 2017, 4:55 PM
Hi Joe,

When In-Browser tests are launched, the app is proxied through Sencha Test, so the URL differs. So any previous cookies/session variables won't apply to the launched app as it's seen as a different domain/address.

One possible solution - could you include a JS file within Sencha Studio, that sets the cookie value? It will be included in the app when it loads in the browser, if that helps?

For example, on the Scenario settings, under Additional Libraries, define a new JS file within the "lib" path, then create a new JS file in Studio under the "lib" folder, containing something like this:


document.cookie = 'MyCookieName=MyCookieValue;expires=Fri, 17 Nov 2017 10:00:00 UTC';

Thanks

jflowers45
15 Nov 2017, 7:57 PM
ha! that worked like a charm on the Sencha forum, at least, when I copied the value of the bb_sessionhash cookie. So I'll see if it works when I'm on the client site next week. Thanks!

daniel.gallo
15 Nov 2017, 8:57 PM
You're welcome, hope it works on the actual app!