Protractor - Chrome is denying access to this webpage when attempting to access it automatically

Currently, I am familiarizing myself with Protractor as the tool for automating website testing. Specifically, I am running tests on the following page: , using Google Chrome browser.

The issue at hand is:

1. Protractor successfully navigates to .

2. Manually accessing by pasting the URL in the browser works fine.

3. When Protractor first goes to and then clicks on "AngularJS Developers" in the BROWSE TOP SKILLS section, it functions correctly.

4. However, if Protractor attempts to directly access using browser.get(url), it fails to load and instead displays the message:

"Access to this web page is denied.

Please ensure that your browser supports JavaScript and cookies and that they are not being blocked. For more information on Upwork's cookie usage, refer to our Cookie Policy."

https://i.sstatic.net/44vZD.png

To keep the test independent, I have created two classes for testing purposes - one for testing the HomePage and another for testing the HirePage. This decision led me to attempt opening the browser directly on in order to avoid having to navigate through the HomePage. The goal is to eliminate dependency between the tests since if the first test fails, so will the second. How can I address this issue?

Below is the code snippet for the HirePage Test:

const HirePage = require("../Pages/HirePage");

let hirePage;
const url = browser.params.HirePageURL;
const expectedHeadLine = browser.params.expectedHeadlineOnHirePage;

beforeAll(function () {
    browser.get(url);
    hirePage = new HirePage();
});

describe("Checks Hire page and filters freelancers after submitting data", function () {

    it("Should display the correct Headline", function () {
        expect(hirePage.headlineUpperText()).toContain(expectedHeadLine);
    });

});

Additionally, here is my cong.js file for reference:

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',

    capabilities: {
        browserName: 'chrome',
        // 'chromeOptions': { 'args': ['incognito'] }
        },


    onPrepare: function() {
        browser.driver.manage().window().maximize();
        browser.manage().timeouts().implicitlyWait(5000);
        browser.manage().timeouts().pageLoadTimeout(10000);
        },

    specs: [
        // './*/HomePageTest-spec.js',
        './*/HirePageTest-spec.js',
    ],
    params: require('./Configuration/configurationFile')
  };

To execute the test, I simply type "protractor conf.js" into the console.

Following advice provided by Yong in the responses, here is a screenshot documenting the process: https://i.sstatic.net/AqhEc.png

Answer №1

Below are the steps to verify Cookies and Javascript settings in Chrome instance launched via Automation:

1) Insert a long delay after opening the URL, allowing enough time to pause the execution to prevent the browser instance from closing.

beforeAll(function () {
    browser.get('https://www.upwork.com/hire/angularjs-developers/');
    browser.sleep(60*1000);
    hirePage = new HirePage();
});

2) Re-run the script, once Chrome is launched and the URL is opened through automation. In the command window, press Ctrl + C, then press Y to halt execution.

3) Open chrome://settings/content in a new tab within the existing unclosed Chrome window.
Capture a screenshot of the cookies and JavaScript settings as displayed below, attach the screenshot to your query.

https://i.sstatic.net/oTZg3.png

Upon reviewing the screenshot, we can determine if the cookies and JavaScript settings are incorrect in the Chrome instance initiated by automation.

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

Preserving proportions in CSS using both width and height measurements

My objective is to set an aspect ratio (for example, 4:3) for a DIV and all its children with the styles WIDTH:100% and HEIGHT:100%. Initially, this method works well by setting the parent's WIDTH:100% and then adding PADDING-BOTTOM: 75%; // (3/4)*1 ...

How can I keep a div open when the mouse hovers over it, and then close it when the mouse

My current markup looks like this: <div class="wrapper-header"> <div class="container"> <div class="navbar"> <ul class="nav navbar-nav"> <li class=""><a href="#" class="toggle">Show Categories</a></li> </ ...

Combining CSV data from multiple arrays into a single object array

After finding inspiration in this thread on storing CSV files in separate arrays, I successfully implemented it. Now, I am hoping to expand my setup by incorporating 8 additional arrays, each containing the contents of CSV files. My main challenge now is ...

Is there a way to confirm if a link is within the same domain before opening it in the current tab?

I am currently working on an Angular 8 application. In this application, there is a specific requirement for handling links. For external links, such as www.ad.nl, clicking on them should open in a new tab. However, if the link belongs to the same domain ...

The HTML Canvas seems to be malfunctioning for some unknown reason

As a beginner in programming, I am struggling to understand why the code below is not working. The first three lines of the script are necessary for another part of the webpage, but I don't see how that would affect the rest of the code: <!DOCTY ...

Querying and Retrieving a List of Nested Documents in MongoDB

I have multiple solutions, each of which may contain various projects. To represent this relationship, I opted for embedding the projects within the solution document. For example: [{ _id: "1", solutionTitle: "Some Sample Solution", p ...

C# - Issue with Webbrowser failing to fully load pages

I am facing an issue with loading pages completely on the web browser, likely due to heavy usage of JavaScript. To address this problem, I have integrated another browser into the project called Awesomium. I am wondering if Awesomium supports using getEle ...

Concentrate on the HTML element once it becomes active

I am facing a challenge where I need to focus on a specific input element. However, there is a spinner that appears on page load and remains hidden until certain http requests are completed. All inputs are disabled until the requests are finished. The setu ...

What is the best way to dynamically render classes based on conditions in a table using React Bootstrap?

I am looking for a way to dynamically change the color of a class based on the transaction data in a table. import React from "react"; import Table from "react-bootstrap/Table"; import "./TableComponent.css"; const TableComponent = ({ Movement }) =&g ...

Issue with disabled button in Angular 2 when using Chrome's autocomplete feature

In a basic login form, the login button is initially disabled with the following code: [disabled]="!password || !loginName" When Chrome's autocomplete feature fills in the values for loginName and password, the button remains disabled after the pa ...

Troubleshooting the display of API-generated lists in Angular 8

I am encountering an issue in Angular 8 when trying to display my list on a page. Below is the code from my proposal-component.ts file: import { Component, OnInit, Input } from "@angular/core"; import { ActivatedRoute, Params } from "@angular/router"; imp ...

Transmit information from JavaScript to a servlet and receive a response in return

I'm new to using ajax and JavaScript. Currently, I have a simple jsp page containing HTML and an accompanying JavaScript file with all my functions defined. One of these functions sends JSON data to a servlet and now I need assistance in receiving th ...

React: automatically close other SubMenus when a new SubMenu is opened

Is there a way to automatically close all other open SubMenus when a user opens a new SubMenu? If anyone has a solution, I would greatly appreciate the help! This is my code: Menu.tsx -> const Menu: React.FC = ({ data }) => { return ( ...

how to prevent autoscrolling in an angular application when overflow-x is set to

In my socket event, I am using $scope.items.unshift(item) to place the new item at the top of the list. The html code includes <ol ng-repeat="item in items"><li>{{item.name}}</li></ol> An issue arises when a new item is added whil ...

Tips for integrating Material UI with useRef

There seems to be an issue with the code, but I haven't been able to pinpoint exactly what it is. My question is: How do you properly use useRef with Material UI? I am attempting to create a login page. The code was functioning fine with the original ...

Guide to incorporating dynamic components into Angular Router

I am currently working on developing a pluggable Angular application. During my research, I came across the following insightful article: Building an extensible Dynamic Pluggable Enterprise Application with Angular Everything was going smoothly until I ...

How can I display the value entered in a text input field when using ajax upload?

Is there a way to display the value of an input type text when using ajax for file upload? I have successfully implemented code to upload files to a directory called attachments_files, but I am facing an issue. How can I retrieve and echo the value from i ...

Loop through a nested array of objects within the same row using ng-repeat

Struggling with binding data from a nested array in the same row. Here is my Array of Objects: $scope.Record = [ { Name:'Adam', Months:[ {Month: 'Jan', Value: 10, cust:2}, {Month: 'Feb', Value: 30, cust:2} {Month: 'M ...

Extract element from Javascript data structure

When working with an object retrieved from mongoose, specifically a user object, I encountered an issue trying to remove the hashed password field. I attempted: apiRoutes.get('/user/:id', function(req, res, next) { User.findById(req.params.id ...

Executing a keystroke in Selenium Webdriver using JavaScript

I've been writing a test using Selenium WebDriverJS, and now I need to simulate pressing a key on the keyboard. Is it possible to do this with Selenium WebDriverJS? If so, how can it be done? In Java, we achieve this as follows: driver.findElement(Lo ...