What is the title of the current URL being tested with Protractor?

It's important to check the current URL and get the title of the HTML page. In my test, I clicked on the "My Account" button but since the user hadn't logged in before, the website redirected to the login page. I then used sendKeys to enter the username and password before clicking the login button. However, even after calling browser.getCurrentUrl() and browser.getTitle(), it still returned the same title as before logging in.

    beforeEach(function () {
    browser.ignoreSynchronization = true;
    browser.get('https://*******************.net/');
});T

it(' children (li) of parent (ul) with class(nav) should have names Login/Register/Forgot Password/Forgot Username', function () {
    var myAccount = element(by.id('navItem_MyAccount'));
    myAccount.click();
    list = element.all(by.css('#tabs-Login li'));    
    expect(list.get(0).getText()).toBe('Login');
    expect(list.get(1).getText()).toBe('Register');
    expect(list.get(2).getText()).toBe('Forgot Password');
    expect(list.get(3).getText()).toBe('Forgot Username');

}, 10000);

it(' logIn should be active', function () {
    var myAccount = element(by.id('navItem_MyAccount'));
    myAccount.click();
    _login = element.all(by.css('.active'));
    expect(list.get(0).getText()).toBe('Login');

}, 1000);

it(' Page Title should be iSportsman: Home ', function () {
    var _login = element.all(by.css('#Login'));
    var log = element.all(by.css('#btnLogin'));
    var _loginPw = element.all(by.css('#inputRow-Password'));
    _login.sendKeys('************************');
    console.log('step1 done');

    _loginPw.sendKeys('*********');
    console.log('step2 done');

    log.click();
    console.log('step3 done');
    var _url = browser.getCurrentUrl();
    console.log(_url.toString());
    browser.get(_url.toString());

    browser.getTitle().then(function (title) {
        expect(title).toEqual('imakerman: Home');
    })

},10000);

});

Answer №1

During the third test, I realized that I had forgotten to click on the account button before entering the username and password with sendKeys. To rectify this, I combined the username and password into one promise and then clicked the login button.

it(' Page Title should be iMaker: Home ', function () {
    var myAccount = element(by.id('navItem_MyAccount'));
    myAccount.click();
    var log = element.all(by.css('#btnLogin'));
    var _login = element.all(by.css('#Login')).sendKeys('*****************');

    console.log('step1 done');

    var _loginPw = element.all(by.css('#Password')).sendKeys('**********');

    console.log('step2 done');

    protractor.promise.all([_login, _loginPw]).then(function () {

     log.click();
    });
    console.log('step3 done');
    browser.getCurrentUrl();

    browser.getTitle().then(function (title) {
        expect(title).toEqual('iMaker: Home');
    })

 },5000);
 });

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Identifying when a page-loading or reloading event has been canceled

When the Cancel button is pressed during page load/reload, the content of the page loads partially. Is there a more effective way to address this issue rather than displaying incomplete content? For instance, consider showing a message such as "Page load ...

Load Angular scripts only when needed

I need to develop an application that can dynamically register new Angular Controllers obtained from a script. This application should load the minimum necessary scripts at startup and then fetch additional scripts as needed from other modules. Here' ...

Displaying a list in Angular 2/4 without keeping track of any modifications

Is there a way to display a list of strings without tracking changes? (I'm experiencing performance issues). Fetching a list of languages from a REST API and then dynamically generating dropdowns for each language using *ngFor is causing the app to s ...

Can you explain the significance of syntax in sample code (typescript, react)?

const sampleFunction: (inputString: string) => string = inputString => { return inputString.split(""); } I'm a bit confused about the code below and would appreciate some clarification. I understand that only "string" as a type is accepted, b ...

How does a web crawler determine which elements to click on when navigating a webpage?

Recently, I developed a crawler application that is able to access a given webpage and extract the HTTP Requests before storing them in an excel sheet. Currently, I have implemented click events for some buttons using jQuery. Now, I am faced with the chal ...

Discover the basics of incorporating libraries using npm

As a beginner in JavaScript, I am looking to incorporate moment.js or another library into my project. However, I am unsure of how to properly set up my project so that I can import from the library. Here is how I have structured my HTML: <!DOCTYPE html ...

An error has occurred: sendEmail function is not defined

There seems to be a simple issue here that needs my attention before diving into PHP tasks. I plan on using PHPMailer this time around. I've been attempting to learn how to submit a form on localhost for the past week, and now I'm going to try i ...

Effortlessly Concealing Numerous Elements with a Single Click in Pure JavaScript

I have successfully created an HTML accordion, but I am facing an issue. I want to implement a functionality where clicking on one accordion button will expand its content while hiding all other accordion contents. For example, if I click on accordion one ...

Javascript initial keypress delay for movement in 3D space

I am aiming for a seamless movement experience when pressing a key - with the object initiating its movement upon the first press and then continuously moving while the button is held down. //setting movement speeds var xSpeed = 0.5; var zSpeed = 0.5; do ...

Unable to iterate over an array within a single file Vue component

I created a vue.js app utilizing single file components. In the data section, I initialized an empty array like this: data: function () { return { teamKeys: [] } }, Next, I populate this array by pushing values into it within one of my methods: ...

Implementing meta tags in React.js

I am attempting to incorporate dynamic meta-tags on each page of my website. However, despite my efforts, I cannot seem to locate the meta-tags in the page's source code. Do I need to make adjustments in public/index.html, considering that I am not ut ...

Meteor - An error occurred in the Subscription Publish Function because it returned an array of non-Cursors

I'm attempting to publish a collection, but my console is showing that it returns an array. server/publish.js HeartCount = new Mongo.Collection('heartcount'); Meteor.publish("currentHeartCount", function() { return HeartCount.find().f ...

What is the process for assigning an element to a specific URL ID?

Imagine having an array of objects structured like this: [{ details: {id: 7}, type: minigame1, ...(more values that need to be accessed later) }, { details: {id: 8}, type: minigame1, ...(more values that need to be accessed later) }, { details: {id: ...

Why does npm/yarn claim that the "license" in my package.json is missing when I have it listed?

Whenever I run yarn install, a warning pops up indicating that there is no license field, despite having defined one as follows: $ jq . package.json { "name": "license-example", "version": "1.0.0", "main": "index.js", "license": "UNLICENSED", " ...

What is the reason for DialogContent displaying a scroll bar instead of expanding further when nested Grids with spacing are included?

My current project involves working on a form displayed in a dialog window. To adjust the layout of the form's fields, I utilize multiple Grid elements nested within another Grid. However, I've encountered an issue where adding any spacing to the ...

What is the best way to manipulate and update individual counters in React components?

I developed a ticket ordering system for a project, but encountered an issue where increasing the quantity of one ticket also resulted in the incrementation of the other ticket's counter. I suspect this occurs because only one value is stored in the s ...

Using Partials in Node.js with Express and Hogan.js

I am currently in the process of building a website using Node.js + Express and utilizing Hogan.js as the view engine. Here is a snippet from my file app.js: // Dependencies var express = require('express') , routes = require('./routes&a ...

Substitute particular value within useRef() array during iteration

I have a situation where I am creating multiple dropdown menus that dynamically update the title when a user selects an option from the dropdown. Each dropdown menu is looped through using useRef and map() array function. Although I was successful in upda ...

discovering identical patterns within a collection of elements

Attempting to identify matching patterns for the string input by the user in a textbox. The code works well in most cases, but there are instances where it does not provide all the required results. Below is a link to a jsfiddle displaying the functioning ...

I'm looking for a solution to enable the execution of 'expandRowByClick' only when clicking on a specific area within the row in Ant Design. Any suggestions?

In my quest to create a expandable table row with Ant Design's built-in expandRowByClick function, I encountered a dilemma. The function allows me to expand a row by clicking anywhere in it, but what if I want this feature to apply only to a specific ...