Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protractor stopped working after it getting redirected from non angular to angularJS(1.5.7) Application #5329

Open
ArunDhananjeyan opened this issue Oct 8, 2019 · 3 comments

Comments

@ArunDhananjeyan
Copy link

Hi Team,
I'm pretty new to protractor and we are trying to build up a framework for one of our Angular application. In which we are facing an issue after application redirecting from non-angular to angularJS(1.5.7) application. Also i have Code snippet and error logs to it if possible could someone help on this please ?

Node Version: v8.11.4
Protractor Version: 5.4.2
Angular Version: 1.5.7
Browser(s): chrome, firefox
Operating System and Version: windows 10 pro
Configuration file:

import { browser } from "protractor";
import {Constant} from "./Utilities/Constants";
// Require protractor-beautiful-reporter to generate reports.
var HtmlReporter = require('protractor-beautiful-reporter');
var ReportportalAgent = require('agent-js-jasmine');

var agent = new ReportportalAgent({
    // client settings
    token: "XXXXXXXXXX-XXX-XXXx-XXXx-XXXXXXXXXXXX",
    endpoint: "http://localhost:8080/api/v1",
    launch: "Demo_Launch",
    project: "PxXXXTEST",
    // agent settings
    attachPicturesToLogs: false,
    tags: ["Ninja","MyCoolTag"]
});

exports.config = {
directConnect: true,

// Capabilities to be passed to the webdriver instance.
capabilities: {
    'browserName': "chrome", 
    chromeOptions: {
        args: ['--disable-gpu', '--disk-cache-size=1', '--media-cache-size=1', 'disable-infobars', 'start-maximized'],
        prefs: {
            'safebrowsing' : {
                'enabled' : true
            },
            'disable-popup-blocking': false,
            'download': {
                'prompt_for_download': false,
                'directory_upgrade': true,
                'default_directory': 'C:\\Downloads\\',
                'extensions_to_open': 'exe'
            }
        }
    }
},

// If you have one app to test then you can mention the base url here.

// Framework to use. Jasmine is recommended.
framework: 'jasmine2',

specs: ['../temp/test-suites/angularjs.spec.js'],

// Options to be passed to Jasmine.
jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 120000,
    isVerbose: true
},

onPrepare: () => {
    browser.manage().window().maximize();
    browser.manage().timeouts().implicitlyWait(5000);
    // Add a screenshot reporter and store screenshots to `./test-results`:
    
    jasmine.getEnv().addReporter(agent.getJasmineReporter());
    
    // jasmine.getEnv().addReporter(new HtmlReporter({
    //     baseDirectory: 'test-results',
    //     preserveDirectory: false, // Preserve base directory
    //     screenshotsSubfolder: 'screenshots',
    //     jsonsSubfolder: 'jsons', // JSONs Subfolder
    //     takeScreenShotsForSkippedSpecs: true, // Screenshots for skipped test cases
    //     takeScreenShotsOnlyForFailedSpecs: false, // Screenshots only for failed test cases
    //     docTitle: 'Test Automation Execution Report', // Add title for the html report
    //     docName: 'TestResult.html', // Change html report file name
    //     gatherBrowserLogs: true // Store Browser logs
    // }).getJasmine2Reporter());
},
afterLaunch() {
    return agent.getExitPromise();
}} 
  • A relevant example test

      it('TestCase1', function () {
    
      browser.get('https://www.localhost/');
    
      browser.element(by.className("button"));
    
     //Navigating to non- angular application
      browser.waitForAngularEnabled(false);
    
      browser.sleep(10000);
    
      browser.element(by.id("thirdPartyIdpEmail")).click();
    
      browser.element(by.id("thirdPartyIdpEmail")).sendKeys("XXXXXXXX@XXXXX.com");
    
      browser.element(by.id("btn-idp-email")).click();
    
      browser.sleep(5000);
    
      browser.element(by.id("loginPassword")).sendKeys("XXXXXXXX");
    
      browser.element(by.id("signin_button")).click();
      
      //Navigating Back to AngularJS(1.5.7) application
      //I have changed angular app root to below CSS element since we have ngApp attribute in             
      //on our body tag 
      /* <body id="mainApp" data-ng-controller="mainCtrl" ng-init="init()" class="is--stratus ng-scope is--chrome is--version--77 has-product-switcher is--desktop is--portrait"> */
      browser.angularAppRoot("#mainApp");
    
      browser.waitForAngularEnabled(true);
    
      browser.sleep(15000);
    
      browser.element(by.xpath("//body[@id='mainApp']/div/div/div/div/div/div/div/ul/li[1]")).isPresent().then(function(_value) {
          console.log(_value);
      });
    
  • Output from running the test
    Error 1:
    `Failures:

  1. AngularJS. TestCase1
    Message:
    Failed: javascript error: Cannot read property 'push' of undefined
    (Session info: chrome=77.0.3865.90)
    (Driver info: chromedriver=76.0.3809.12 (220b19a666554bdcac56dff9ffd44c300842c933-refs/branch-heads/3809@{NoSuchElementError when finding an element that does not yet exist. #83}),platform=Windows NT 10.0.18362 x86_64)
    Stack:
    JavascriptError: javascript error: Cannot read property 'push' of undefined
    (Session info: chrome=77.0.3865.90)
    (Driver info: chromedriver=76.0.3809.12 (220b19a666554bdcac56dff9ffd44c300842c933-refs/branch-heads/3809@{NoSuchElementError when finding an element that does not yet exist. #83}),platform=Windows NT 10.0.18362 x86_64)
    at Object.checkLegacyResponse (C:\Users\Administrator\Downloads\protractor-jasmine-typescript-master\protractor-jasmine-typescript-master\node_modules\selenium-webdriver\lib\error.js:546:15)
    at parseHttpResponse (C:\Users\Administrator\Downloads\protractor-jasmine-typescript-master\protractor-jasmine-typescript-master\node_modules\selenium-webdriver\lib\http.js:509:13)
    at doSend.then.response (C:\Users\Administrator\Downloads\protractor-jasmine-typescript-master\protractor-jasmine-typescript-master\node_modules\selenium-webdriver\lib\http.js:441:30)
    at
    at process._tickCallback (internal/process/next_tick.js:188:7)
    From asynchronous test:
    Error
    at Suite. (C:\Users\Administrator\Downloads\protractor-jasmine-typescript-master\protractor-jasmine-typescript-master\test-suites\angularjs.spec.ts:22:5)
    at Object. (C:\Users\Administrator\Downloads\protractor-jasmine-typescript-master\protractor-jasmine-typescript-master\test-suites\angularjs.spec.ts:12:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)

1 spec, 1 failure
Finished in 58.124 seconds

[16:35:14] I/launcher - 0 instance(s) of WebDriver still running
[16:35:14] I/launcher - chrome #1 failed 1 test(s)
[16:35:14] I/launcher - overall: 1 failed spec(s)
[16:35:16] E/launcher - Process exited with error code 1
npm ERR! Test failed. See above for more details.`

Also I have tried to set Protractor as Non-Angular Application whereas I'm getting new issue

Error 2:
`Failures:

  1. AngularJS. TestCase1
    Message:
    Failed: invalid argument: Unsupported locator strategy: null
    (Session info: chrome=77.0.3865.90)
    (Driver info: chromedriver=76.0.3809.12 (220b19a666554bdcac56dff9ffd44c300842c933-refs/branch-heads/3809@{NoSuchElementError when finding an element that does not yet exist. #83}),platform=Windows NT 10.0.18362 x86_64)
    Stack:
    WebDriverError: invalid argument: Unsupported locator strategy: null
    (Session info: chrome=77.0.3865.90)
    (Driver info: chromedriver=76.0.3809.12 (220b19a666554bdcac56dff9ffd44c300842c933-refs/branch-heads/3809@{NoSuchElementError when finding an element that does not yet exist. #83}),platform=Windows NT 10.0.18362 x86_64)
    at parseHttpResponse (C:\Users\Administrator\Downloads\protractor-jasmine-typescript-master\protractor-jasmine-typescript-master\node_modules\selenium-webdriver\lib\http.js:509:13)
    at doSend.then.response (C:\Users\Administrator\Downloads\protractor-jasmine-typescript-master\protractor-jasmine-typescript-master\node_modules\selenium-webdriver\lib\http.js:441:30)
    at
    at process._tickCallback (internal/process/next_tick.js:188:7)
    From asynchronous test:
    Error
    at Suite. (C:\Users\Administrator\Downloads\protractor-jasmine-typescript-master\protractor-jasmine-typescript-master\test-suites\angularjs.spec.ts:22:5)
    at Object. (C:\Users\Administrator\Downloads\protractor-jasmine-typescript-master\protractor-jasmine-typescript-master\test-suites\angularjs.spec.ts:12:1)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)

1 spec, 1 failure`

  • Steps to reproduce the bug
  • The URL you are running your tests against (if relevant)
@testershruti01
Copy link

I have the same issue. unable to find elements from page after non-angular page get redirect to angular Page..
.Did u got the resolution?

@ArunDhananjeyan
Copy link
Author

Hi @testershruti01,
It seems to be an application issue which is issue appearing only chrome version < 75. Also I have raised a ticket to my dev team against it but they haven't respond back to me

@testershruti01
Copy link

Hello I got the resolution for this was getting same issue when page redirect from non angular page to angular page. i have ngwebdriver which is a static variable I have reintialized it, and now its working as I want.

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

No branches or pull requests

2 participants