Establishing baked goods in protractor

Attempting to create a cookie in a protractor testing scenario. Using Protractor 3.3.0, Angular 1.5.x, and Node.js 6.9.1

Here is the specified test:

(function() {
    'use strict';

    describe('Dummytest', function() {
        beforeEach(function() {
            browser.get('./');
        });

        it('should set a cookie', function() {
            browser.manage().addCookie("test", "fail_cookie", '/', 'localhost');
        });
    });
})();

An error message is generated as follows:

browser.get wasn't used prior to successful cookie read/write operations.

(function() {
    'use strict';

    describe('Dummytest', function() {
        it('should set a cookie', function() {
            browser.manage().addCookie("test", "fail_cookie", '/', '127.0.0.1');
            browser.manage().getCookie('test').then(function(cookie) {
                console.log('cookie test', cookie);
                browser.get('./');
                browser.manage().getCookie('test').then(function(cookie) {
                    console.log('cookie test 2', cookie);
                });
            });
        });
    });
})();

The output generated displayed below:

browser.get('./'). How can I establish a cookie for that domain without triggering the initial error?

Further Update:

Discovered a related query (Setting cookies before browser.get) suggesting to initiate with browser.driver.get first, followed by setting the cookie. However, utilizing this method led to the same UnableToSetCookieError. Seek alternative resolutions.

Additional Notes:

In addition to the issues mentioned above, locating documentation pertaining to the addCookie function and its parameters has proven challenging. Especially since the latest release of Protractor (as of 2016-01-31) requires an object rather than a list of parameters. Fortunately, found the essential information and included a reference link here: https://github.com/SeleniumHQ/selenium/blob/022644c47c643ce6fe797...

Final Edit:

Making progress! Setting the domain to .localhost (with the dot at the start) appears to have resolved the issue. Further investigations underway with findings to follow. Appreciate insights on why the dot holds significance and why that specific domain address works effectively :)

Answer №1

Changing the baseUrl to 127.0.0.1 within my protractor.conf.js file appears to have resolved a problem I was encountering.

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

Node.js Module's function is having trouble with exporting

I'm currently working on creating utility functions in Python and I am familiarizing myself with Node.js. However, I am facing an issue where a function is not exporting properly; it keeps saying "SaveJson is not a function". exports.mySaveJson = fun ...

Error: The specified schema for the model "superheroes" is missing and has not been registered. Please ensure the schema is properly defined and registered

After updating my server with nodemon, I encountered the following error: C:\Users\mikae\Desktop\Project\node-express-swig-mongo\node_modules\mongoose\lib\index.js:523 throw new mongoose.Error.MissingSchem ...

Managing numerous API requests in React Native

As I work on implementing a search field, I've encountered a challenge. Whenever a user enters text in the search field, a timer resets to 300 ms before an API call is sent to fetch autocomplete results. After receiving these results, the app then wai ...

Encountering an angular circular reference issue while trying to log exceptions with the use of

I am facing an issue with my custom logging setup in Angular. I have overridden the $exceptionHandler to log exceptions using my Logging service, which relies on $http for logging. However, this creates a circular reference problem. Do you have any suggest ...

"Learn the technique of animating SVG paths with JavaScript, a step beyond traditional HTML filling

I am looking to animate SVG path elements with JavaScript instead of HTML. I have come across numerous articles discussing how to achieve this through JavaScript and jQuery by manipulating the attributes. Some helpful links I found: Fill color SVG path w ...

JavaScript and Angular are being utilized, incorporating code from various .ts files

Currently, I am working on a project with Angular4. I have successfully created a filter in my app.component.ts which is functioning well in my app.component.html. <button (click)="filterBy('cars')">Cars</button> Even though the fil ...

Eliminate spacing in MaterialUi grids

As I work on a React project, I am faced with the task of displaying multiple cards with content on them. To achieve this layout, I have opted to use MaterialUi cards within Material UI grids. However, there seems to be an issue with excessive padding in t ...

Dividing Step Definitions

My current setup includes a single Java class (Step Definitions.java) that contains all the following annotations: @Before, @After, @Given, @When, @Then I am looking to divide these annotations into three distinct classes. One class for @Before / @After ...

Boost Page Speed with Angular

Currently, I am working on a project using Angular and encountered an issue with testing the page speed on GTmetrix. Despite generating the build with the command ng build --prod--aot, the file size is 1.9mb, leading to a low speed in GTmetrix's analy ...

AngularJS: Sending form data to an external server results in an error due to restricted URI access

I am currently diving into the world of AngularJs and putting effort into mastering it. In this process, I've created a demo application that attempts to send form data to a localhost site. The code for this endeavor is provided below. index.html &l ...

Understanding the Typescript definitions for different event types in React

How do I properly define the type for React events? In the beginning, I simply used any to keep things simple. However, I am now trying to improve my code and eliminate the use of any altogether. Here is a basic example: export interface LoginProps { l ...

When the page is dynamically loaded, Ng-repeat does not function as expected

I am working on a page that includes the following code snippet: <script> angular.module('myapp', []).controller('categoryCtrl', function($scope) { $scope.category = <? echo json_encode($myarr); ?>; $scope.subcatego ...

Having trouble loading JSON data in your ExtJS Tabpanel?

I have a tabpanel set up with two panels, and I am fetching data via JSON. The data retrieval works perfectly in the first tabpanel, but I'm facing issues parsing the JSON data in the second tabpanel. Any suggestions on how to approach this? var regi ...

Deleting a nested object from an array within another object

Recently, I delved into the world of Redux and have found it quite fascinating. However, I am currently facing a dilemma where my new reducer function inadvertently changes the type of a state variable, which is not what I intended. The desired structure ...

The error in ReactJS is coming from the render method of the `News` component

While working with React JS, I encountered an error when trying to run a particular code snippet. The error message displayed was: "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got ...

Import a picture file into Photoshop and position it at a designated location

I need assistance with developing a function that can load an image and position it at specific x, y coordinates in Photoshop. Below is the code I have so far: var docRef = app.activeDocument; function MoveLayerTo(fLayer, fX, fY) { var Position = fLaye ...

What could be causing the unusual alignment of the 'pixels' on my resized HTML5 canvas?

Currently, I am in the process of creating a simple HTML5 canvas/JavaScript snake game inspired by the classic Nokia Snake. This is my first attempt at developing a game using HTML5 canvas and JavaScript, and I must admit, I am still a novice programmer! ...

Storing table rows in an array using Javascript

I've encountered a situation where I have a PHP script generating a string of table rows that is then returned via an AJAX request. This generated string consists of all the content enclosed within the tbody tags (<tr>1</tr><tr>2< ...

To interact with an image in Selenium that has the same source (src) as other images and does not have an

There are 3 rows in a table layout where an image serves as an edit button for each row individually, all identical. To edit a particular row, I must click on the image with a dynamic id of 1526885146519. I need to click on all edit buttons one by one. Wha ...

What is the best way to retrieve results by passing an array in MongoDB?

I currently have an array that I am using to search for specific products. The array is displayed below. "productIds": [ { "productId": ObjectId("574592dfc07f13943255c19d") }, { "productId": ObjectId("5745934cc07f13943255c19f") }, ...