angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

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

Open ArunDhananjeyan opened 5 years ago

ArunDhananjeyan commented 5 years ago

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();
}} 

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 #01 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@{#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@{#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`

testershruti01 commented 5 years ago

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 commented 5 years ago

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 commented 4 years ago

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.