Accessing a file url with Firefox using protractor

I am currently facing a challenge with Protractor as I try to access an HTML file as a website using it. Whenever I attempt to do so, I encounter an error from Protractor stating:

    Failed: Access to 'file:///C:/filelocation/index.html' from script denied
    Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12'
    System info: host: 'BAHCND4397GQF', ip: '10.138.1.189', os.name: 'Windows 7', os.arch: 'amd64',os.version: '6.1', java.version: '1.8.0_72'
    Driver info: driver.version: unknown

After some research online, I discovered that the issue was specific to Firefox and can be resolved by adding the following lines to a 'user.js' file:

    user_pref("capability.policy.policynames", "localfilelinks");
    user_pref("capability.policy.localfilelinks.sites", "C:/MendisSoftwareList/Software%20List/cwmdt-applications-parent/common-parent/index.html");
    user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");

I learned that this 'user.js' file must be located in the Firefox Profile I am using, which I have placed here:

    C:\Users\userName\AppData\Roaming\Mozilla\Firefox\Profiles\Profile

Unfortunately, despite my efforts, I have not been successful in resolving the issue. I am now seeking any assistance or guidance on how to proceed further. Below are some resources I have consulted:

https://groups.google.com/forum/#!msg/selenium-users/Guh9x4HEWls/pbEjrsq5pXUJ
http://kb.mozillazine.org/User.js_file
https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/6373

Thank you for your help.

Answer №1

After some searching, I stumbled upon a helpful resource that partially addresses the question at hand: Opening a file with protractor

While this solution meets my current needs, I am eager to delve deeper into the topic for both personal growth and the benefit of the community. Feel free to provide additional answers or share your thoughts in the comments section.

Thank you!

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

Retrieve all descendant elements

Is it feasible to retrieve all the child elements of a WebElement in Selenium using Python and store them in a list? ...

Contrasting the uses of element(...) versus element(...).getWebElement() in Protractor

What is the advantage of using element(...).getWebElement() instead of element(...) when they both perform similarly? Why are there two different APIs for the same purpose? ...

A step-by-step guide to adding an object to an already existing array in Vue.js

Within the code snippet below, I am dealing with an object value and trying to figure out how to push it to an existing array. methods: { onChange(event) { this.newItems.push(event.target.value); console.log(event.target.value); } } Here is m ...

Using Python to gather data from the command line

I'm currently working on a script to extract m4a files from a specific website. I am utilizing BS4 and selenium for this task at the moment. I am encountering some difficulty in retrieving the necessary information. The file link is not present in th ...

Automatically transfer CSV files to Google Sheets with Python and Selenium

I've encountered an issue while trying to upload a CSV file to a specific cell in Google Sheets using Selenium. Despite having the cell selected and the upload pop-up open, whenever I attempt to use the "send_keys" method, I receive an "element not in ...

Endless asynchronous loops with setInterval()

My nodejs application requires multiple infinite loops that call asynchronous functions. I was contemplating the following approach: async function process1() { ...perform some asynchronous tasks... } async function process2() { ...perform some as ...

How to defer the rendering of the router-outlet in Angular 2

I am currently working on an Angular 2 application that consists of various components relying on data fetched from the server using the http-service. This data includes user information and roles. Most of my route components encounter errors within their ...

The Simple HTML Dom parser is failing to parse contents on these specific websites

I tried using a basic HTML DOM parser but it's encountering issues when parsing certain websites. include_once 'simple_html_dom.php'; $html=file_get_html('http://www.lapenderiedechloe.com/'); This results in an error message like ...

Which is more effective: using the try-catch pattern or the error-first approach

My main focus is on node.js and express.js, although I am relatively new to JavaScript overall. When it comes to error handling, the official recommendation is to use the try-catch pattern. However, some developers argue in favor of sticking with the tradi ...

Obtain the Week Input's Value

Is there a way to store the value of a week input in a variable and then display it in a span? I attempted the following code: <input type="week" name="week" id="week-selector"> <span id="kalenderwoche"> ...

What are the steps to utilize an npm package effectively?

Although I have a great appreciation for npm and nodejs, I am struggling to understand css, let alone JavaScript. I know that this is a big part of the problem. My main question is: when I use npm to install a package, how can I Find ALL available comma ...

choosing a specific element within an HTML string stored in a variable

I have a variable containing HTML string data like this: var htmlstring = "<div><div class='testdiv'>924422</div></div>" My goal is to extract the content of the div with a specific class, in this case .testdiv. How ca ...

Error: The validation process failed due to missing information. The file name and path are both required for validation

In my current project, I am attempting to upload a file from the frontend to the backend and save it. However, I am encountering an error that looks like this: Error The error message is as follows: this.$__.validationError = new ValidationError(th ...

Can a JavaScript function be sent back via AJAX from PHP?

Can a javascript function be returned via Ajax from php? Typically, I would just return a value and handle it in plain javascript. However, since I am working on an Apache Cordova mobile app, I need to approach things differently. account = localStorage.g ...

Navigating to a URL using "res.render" following the process of fetching POST data from the DOM array in Node.js

Despite browsing through numerous related questions, I am still unsure about the best approach to render a URL after the frontend JavaScript collects DOM data and sends a POST request to an Express server's POST URL. I understand that fetch POST does ...

What could be causing the React text input to constantly lose focus with every keystroke?

In my React project using Material-UI library, I have a component called GuestSignup with various input fields. const GuestSignup = (props: GuestSignupProps) => { // Component code goes here } The component receives input props defined by an ...

JavaScript encountered an issue when trying to display HTML content

Through my PHP code, I am attempting to create a popup window that displays the content of an HTML file. However, after adding script tags, no HTML content is displayed. When I tried echoing out $row2, only the word 'array' appeared on the screen ...

Navigating Through the DOM with Selenium using XPath Axes

Currently, I am developing Selenium tests for a dynamic web page. Within this section of code, I am extracting data from an Excel sheet and verifying if a specific element exists on the webpage. I have annotated the critical part of the code with comments ...

What are the steps to take in order to successfully deploy an Express server on GitHub Pages?

I heard that it's possible to host an Express server on GitHub Pages, but I'm not sure how to do it. Is the process similar to deploying a regular repository on GitHub Pages? ...

Inside nested ng-transclude, the AngularJS directive isolates the scope

I've been scouring the internet for a solution to my problem, but I still haven't found it. In my application, I have a directive that enables users to sort and search through various lists of items. These items can vary in type and usage, leadi ...