Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Using Protractor to run tests against multiple user roles #1088

Closed
jpetraws opened this issue Jul 18, 2014 · 10 comments
Closed

Using Protractor to run tests against multiple user roles #1088

jpetraws opened this issue Jul 18, 2014 · 10 comments

Comments

@jpetraws
Copy link

I am trying to run the same test for different roles in the application.

The problem is since there is no logout/login page(SSO magic). I can't logout and login is a different user on the same browser.

I have been trying to get around this and look up a way to pull up a new browser instance or anything.

The only thing that got kind of close was if I tried to use multiCapabilities:

multiCapabilities: [{
    browserName: 'chrome',
    acceptSslCerts: true,
    trustAllSSLCertificates: true,
    specs: ['claimsoverview/login-claims-analyst.spec.js']
}, {
    browserName: 'chrome',
    acceptSslCerts: true,
    trustAllSSLCertificates: true,
    specs: ['claimsoverview/login-supervisior.spec.js']
}],

Each individual spec works, but when I run them together they do not and I get Unknown error unsupported protocol. And also Error: Error while waiting for Protractor to sync with the page: {}

Before each test I have to hit an Oracle SSO page which is non-angular then I can finally be re-routed to the url that is angular.

//Here is the beginning of one spec..
it('should load homePage from Oracle Sign in Page', function() {

   var dvr = browser.driver;

    //To get around the untrusted cert issue per browser
    dvr.get('https://url');
    UntrustedCertOverride(dvr);

    //Get SSO PageObject and run login()
    var oracleSsoPage = new OracleSsoPage(dvr);
    oracleSsoPage.login(browser.params.claimsAnalyst.userName, browser.params.claimsAnalyst.password);

    //Expect the title to be ConDOR
    expect(browser.getTitle()).toEqual("homePage");
});
@jpetraws
Copy link
Author

I believe I am getting the unsupported protocol because I hit an empty spec initially then run the specs I want for the multiple browsers. I did this to get around the error protractor throws for not defining a main spec to run first.

//Have to have this so I can individual specs per role in multi-capabilities 
describe('start spec', function() {
    it('should do nothing so I can run role specs', function() {
      //Do Nothing
    });
});

@juliemr
Copy link
Member

juliemr commented Jul 22, 2014

@jpetraws the latest version of Protractor should not throw an error if there is not a main spec. Do you still see issues on the latest version? If so, can you clarify what you mean by 'unsupported protocol' - where do you see this message?

@jpetraws
Copy link
Author

updating to the latest version is just:

npm update -g protractor

right?

I have updated and as long as I get a new browser instance per spec I can get it to work.

Is there anyway to pull up a new browser at the beginning of a spec?

@juliemr
Copy link
Member

juliemr commented Jul 22, 2014

Yes, your update method is correct.

No, there is no way to get a new instance of the browser at the beginning of the spec. Doing it with multiCapabilities is the right way to go.

@jpetraws
Copy link
Author

Here is my multi-caps section. All of the browsers work individually but once I bundle IE in there with chrome and firefox, I start getting errors on random instances.

multiCapabilities: [{
    browserName: 'firefox',
    specs: ['claimsoverview/login-manager.spec.js']
}, {
    browserName: 'firefox',
    specs: ['claimsoverview/login-supervisor.spec.js']
}, {
    browserName: 'firefox',
    specs: ['claimsoverview/login-claims-analyst.spec.js']
}, {
    browserName: 'chrome',
    specs: ['claimsoverview/login-manager.spec.js']
}, {
    browserName: 'chrome',
    specs: ['claimsoverview/login-supervisor.spec.js']
}, {
    browserName: 'chrome',
    specs: ['claimsoverview/login-claims-analyst.spec.js']
}, {
    browserName: 'ie',
    specs: ['claimsoverview/login-manager.spec.js']
}, {
    browserName: 'ie',
    specs: ['claimsoverview/login-supervisor.spec.js']
}, {
    browserName: 'ie',
    specs: ['claimsoverview/login-claims-analyst.spec.js']
}],

Here are the results with different failures on different browsers each time

Try #1:

[launcher] 0 instance(s) of WebDriver still running
[launcher] firefox #1 passed
[launcher] firefox #2 failed 3 test(s)
[launcher] firefox #3 passed
[launcher] chrome #4 passed
[launcher] chrome #5 passed
[launcher] chrome #6 passed
[launcher] ie #7 passed
[launcher] ie #8 passed
[launcher] ie #9 failed 3 test(s)
[launcher] overall: 6 failure(s)

Try #2:

[launcher] 0 instance(s) of WebDriver still running
[launcher] firefox #1 failed 1 test(s)
[launcher] firefox #2 passed
[launcher] firefox #3 passed
[launcher] chrome #4 passed
[launcher] chrome #5 passed
[launcher] chrome #6 passed
[launcher] ie #7 failed 2 test(s)
[launcher] ie #8 failed 2 test(s)
[launcher] ie #9 passed
[launcher] overall: 5 failure(s)

Here are the stack traces:

[firefox #2]      Error: Error while waiting for Protractor to sync with the page: {"message":"angular is not defined","stackTrace":

[ie #1]    Message:
[ie #1]      UnknownError: JavaScript error in async script. (WARNING: The server did not provide any stacktrace information)
[ie #1] Command duration or timeout: 207 milliseconds
[ie #1] System info: host: , os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_60'
[ie #1] Session ID: bdaec59e-3cee-4114-a597-378bc35e4a0b
[ie #1] Driver info: org.openqa.selenium.ie.InternetExplorerDriver
[ie #1] Capabilities [{platform=WINDOWS, javascriptEnabled=true, elementScrollBehavior=0, ignoreZoomSetting=false, enablePersistentHover=true, ie.ensureCleanSession=false, browserName=internet explorer, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss, version=9, ie.usePerProcessProxy=false, cssSelectorsEnabled=true, ignoreProtectedModeSettings=false, requireWindowFocus=false, handlesAlerts=true, initialBrowserUrl=http://localhost:43995/, ie.forceCreateProcessApi=false, nativeEvents=true, browserAttachTimeout=0, ie.browserCommandLineSwitches=, takesScreenshot=true}]

@juliemr
Copy link
Member

juliemr commented Jul 22, 2014

Your new problem is a dupe of #1052

Closing this issue since the main problem seems solved!

@juliemr juliemr closed this as completed Jul 22, 2014
@jpetraws
Copy link
Author

Ah ok, thanks Julie!

@skidvd
Copy link

skidvd commented May 5, 2017

@jpetraws Thanks for posting this.

I too am attempting to perform some tests with differing specs for each required role. Surprisingly, this does not seem to be supported in any other manner than what you have demonstrated. Please let me know if you may have found other avenues as I'm still searching.

While your approach accomplishes the main goal of being able to have different specs for each role, I believe it has one drawback. Perhaps you may have a way around this as well? The drawback that I see with this approach, is that we can no longer use the suites capabilities and consequently invoke protractor to only run a subset of suites (--suite=suite1,suite2). Any thoughts on this?

TIA!

@makwanaparth94
Copy link

I want to add multiple credential at run time while running my automation test for Login screen.
How can i do that?

@stgakki
Copy link

stgakki commented Jul 22, 2017

  1. Write one function for login.
  2. Add multiple credentials in json file
  3. Include json file using [ var myjsonData = require("../myjson.json"); ]
  4. Iterate using loop and call login function in it and pass parameters to function as data in json file randomly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants