PDA

View Full Version : NEWBIE: Writing a test to get around a login page



flare_chris
13 Jul 2017, 1:57 PM
Hi
I'm totally new to SenchaTest, and am hitting a hurdle at the first step.

I want to test my site, which for arguments sake is at https://www.mytestsite.com/home/index.html
However, to get there I first need to log in, so the site redirects me from home/index.html to https://mytestsite.com/login.html where I enter my username and password, and hit a Login button. I'm then taken back to my original url: https://www.mytestsite.com/home/index.html and all's well.

I'm trying to use SenchaTest's Event Recorder to write a test to check that the home/index.html loads up correctly, checking certain words and buttons are in the right place, etc..

However, when I use Event Recorder (using IE11) I can get as far as recording the entry of the username, the password and hitting the Login button, but the redirect to home/index.html isn't happening, on clicking the Login button I'm only going to https://www.mytestsite.com/ and of course that's not where I'm supposed to be.

My Project settings seem OK. Location (URL) is https://www.mytestsite.com/
Allowed Globals *
Test Framework Jasmine
No Additional Libraries
No Code Coverage filters.

My Scenario settings:
Test Type: In-Browser
Location (URL): home/index.html
Allowed Globals (additional): *
Test framework: Inherited (Jasmine)

So so far I'm able to test the login process is working, as in the Username and password fields are filled in and the Login button is clicked when I run my test but I'm not ending up at home/index.html, I'm just ending up at / and that's just giving me a 404 error.

Any advice would be very welcome!
Thanks
CA

daniel.gallo
13 Jul 2017, 4:03 PM
For In-Browser scenarios, page navigation isn't supported as this redirects away from the Sencha Test proxied version of the application. This proxied version of the app enables the product to inject the Sencha Test framework and test suites, in order to test the app in-browser.

Have you tried the same actions with a WebDriver scenario? WebDriver tests run sandboxed outside of the browser and support page navigation.

If you're looking for some example test suites focussed around multi-page apps and page navigation, feel free to take a look at the test suites here, which run within a WebDriver scenario: https://github.com/DanielGallo/AssetRegisterTests/tree/master/test/End-to-End.

Thanks for trying Sencha Test - let us know if you have any further questions!

flare_chris
6 Sep 2017, 8:25 PM
Daniel
Thanks very much for your quick reply, and my apologies for my tardiness in appreciating it.
I grasp what you're saying about using the WebDriver scenario, so I've switched to that, and I've also upgraded to SenchaTest 2.2 Early Access, which seems to have an embedded selenium server with Chrome webDriver, or am I misunderstanding that?
I have created a WebDriver Farm, and added a Pool containing webdrivers for Chrome, IE, Edge and Firefox.
I'm still having a similar problem though...

I want to use Event Recorder, so I've created a jasmine test file, clicked to start Event Recorder, and when prompted I'm choosing Embedded -> Chrome. This starts up a Chrome window, under Sencha's control, and tries to open the target URL, say https://www.mytestsite.com:8443/csa/index.html
My application is using a Spring framework, and any user not already logged in is redirected to https://www.mytestsite.com:8443/login.html.
This opens the login page I expect to see, but it also pops up a Chrome authentication dialog, which I don't get when I log into my application outside of SenchaTest:
56866

I cancel that popup and enter my username and password in the login page, and click the Login button. When I do this normally, outside of SenchaTest, I would now be taken back to https://www.mytestsite.com:8443/csa/index.html and I would see a dashboard screen for my application.
However, when I click Login in the webdriver Chrome session, I get taken to a ~orion/files/event/timer-worker.js location and a 404 error is generated:

56867

Back in Event Recorder, things have been recorded as I would expect:
56868

I have tried with Event Recorder using Pool -> IE and I get this error:

Error: A new session could not be created. at url("https://www.mytestsite.com:8443/csa/index.html") - C:\Program Files\Sencha\Test\2_2_0_61\resources\app.asar\node_modules\orion-core\serve\context\WebDriverRecorder.js:41:18 at init() - C:\Program Files\Sencha\Test\2_2_0_61\resources\app.asar\node_modules\orion-core\serve\context\WebDriverRecorder.js:36:18

With Pool -> Chrome I get this error:
Error: An unknown server-side error occurred while processing the command. at url("https://www.mytestsite.com:8443/csa/index.html") - C:\Program Files\Sencha\Test\2_2_0_61\resources\app.asar\node_modules\orion-core\serve\context\WebDriverRecorder.js:41:18 at init() - C:\Program Files\Sencha\Test\2_2_0_61\resources\app.asar\node_modules\orion-core\serve\context\WebDriverRecorder.js:36:18

Using Pool -> Edge the WebDriver session just hangs once the Edge authentication popup appears, I can't enter anything or cancel out of it, I have to kill Studio to get out of that.

Using Pool -> Firefox, a firefox session starts under Sencha control, but then it pops up its own authentication dialog, which shouldn't happen, and once I cancel it and enter my credentials in my login page and click the login button, I get the same timer-worker.js problem.

Any advice you could offer to get this redirection from https://www.mytestsite.com:8443/login.html to https://www.mytestsite.com:8443/csa/index.html working would really help!

Thanks again
Chris Armstrong

craigcomstock
11 Sep 2017, 10:10 AM
The error regarding timer-worker.js should not have an impact generally. Though it does seem to be impacting you. We may be able to address this particular issue in the future. Doing some research it seems that the Whitelabel error page is a generic error page for Spring Boot. What I don't understand is if the error of timer-worker.js not being found is affecting that somehow since that would be a browser-side error.

Regarding IE, did you setup an appropriate IE driver? I usually place the IEDriver executable alongside selenium standalone jar. Your configuration might be different.

Regarding the Pool->Chrome error, does your site have a CSP (content security policy)? If so, we may not be able to load our scripts that are required. Workaround there is to turn off CSP in a dev/test environment if possible.

You might increase the verbosity of error reporting for the other issues in your Pool since the errors you include don't give much to go on.