Avoiding the IE certificate alert by driving with a lead foot

My current challenge involves executing JavaScript in the browser of the client where my intern/selenium/leadfoot tests are running. Specifically, I am attempting to bypass the certificate warning on IE8 & 9.

In the past, using selenium-python bindings, I was able to use the following code to handle the warning if it appeared:

if "Certificate" in driver.title:
    driver.get("javascript:document.getElementById('overridelink').click();")

Now, with leadfoot, I have experimented with various combinations like:

.get(require.toUrl('https://secure-url.com')
.execute("document.getElementById('overridelink').click();")
// OR
.get("javascript:document.getElementById('overridelink').click();")

However, I am unable to successfully execute this JavaScript on the client. Has anyone managed to achieve this?

.execute('alert("hello");')

This works fine on other pages, but not on this particular page. It seems like leadfoot is restricted from running JS on this security page, unlike the selenium API.

Eventually, it results in the following error:

JavaScriptError: [POST http://localhost:4444/wd/hub/session/1fa8a4a3-8774-46af-ad87-0e8fbc5a1388/execute / {"script":"document.getElementById('overridelink').click();","args":[]}] JavaScript error (WARNING: The server did not provide any stacktrace information)

Command duration or timeout: 30 milliseconds

Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'

System info: host: 'IE9Win7', ip: '169.254.0.207', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_67'

Session ID: 8b20796a-1d40-48ad-82e1-25ce16a40f17

Driver info: org.openqa.selenium.ie.InternetExplorerDriver

Capabilities [{platform=WINDOWS, javascriptEnabled=true, elementScrollBehavior=0, ignoreZoomSetting=false, enablePersistentHover=true, ie.ensureCleanSession=false, browserName=internet explorer, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss, version=9, ie.usePerProcessProxy=false, cssSelectorsEnabled=true, ignoreProtectedModeSettings=false, requireWindowFocus=false, handlesAlerts=true, initialBrowserUrl=http://localhost:29797/, ie.forceCreateProcessApi=false, nativeEvents=true, browserAttachTimeout=0, ie.browserCommandLineSwitches=, takesScreenshot=true}]

  at Server._post  <node_modules\intern\node_modules\leadfoot\Server.js:68:9>
...

I can also confirm that WebDriverIO allows me to bypass the warning using the following code snippet:

client.url("javascript:document.getElementById('overridelink').click();")

Answer №1

To bypass the Certificate Error page, I utilized a method to send tab key commands in order to navigate to the override link and press enter as shown below:

.pressKeys([Keys.TAB, Keys.TAB, Keys.TAB, Keys.ENTER])

While there may be alternative approaches, this one proved effective.

For reference, here is an example of how this could be implemented:

        var command = this.remote;
        return command
            .get(require.toUrl('https://portal-stg.vpc.locusdev.net'))
            .getPageTitle()

            // Handling IE Certificate Error
            .then(function(title) {
                if (title.indexOf('Certificate Error') !== -1) {
                    command.pressKeys([Keys.TAB, Keys.TAB, Keys.TAB, Keys.ENTER])
                }
                return true;
            })

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

What is the process for testing promise functions that contain an internal promise using Jasmine in an Angular environment?

In my service function, here's how it looks: asyncGetStuff: (id) -> stuff = [] @asyncGetItem id .then (item) -> #parse some data stuff.push data return stuff Now I am trying to verify the contents of 'stuff': ...

The Uglify task in Grunt/NPM is having trouble with this particular line of JavaScript code

Whenever I execute grunt build, Uglify encounters a problem at this point: yz = d3.range(n).map(function() { return k.map(x -> x[1]); }), An error message is displayed: Warning: Uglification failed. Unexpected token: operator (->). I have recentl ...

Utilizing Dojo DGrid to customize the appearance of data within cells

I am facing an issue with my dgrid where I want to style cells by underlining the text when the checkboxes are selected for the row. My initial approach was to add a CSS class to the item once the checkbox is checked for the row. However, this method did ...

Utilizing Odoo Point of Sale feature on product selection

Can someone help me identify the function that is triggered when a product is clicked on at the point of sale? I am looking to add some code that will automatically apply a discount when a product is added to an order. Appreciate any assistance! ...

update and refill the dropdown menu

I have successfully created a select box using PHP code to display items, but now I need help with dynamically refreshing this select box when new items are added. Specifically, I want the select box to update without refreshing the entire page when an i ...

Every single data attribute is unique for each element

Hello! I'm currently working on creating a sorting system for pictures, documents, and videos. Each div contains data-extension attributes, so my plan is to filter out all attributes that are jpg, gif, or png and make them visible while hiding the oth ...

Inquiry regarding the setTimeout function requiring an answer

I have a question about how setTimeout works. Does it wait for the previous code to finish executing before moving on to execute something else after a set time, or does it simply wait for a specific amount of time and then continue with the rest of the co ...

Preventing page re-rendering with redux when a condition is not met

I am currently working on a page that features a question paper with multiple options and a button to navigate to the next question. import Grid from "@material-ui/core/Grid"; import Typography from "@material-ui/core/Typography"; import React, { useEffec ...

When Vue.js Vuex state changes, the template with v-if does not automatically refresh

I have tried setting the v-if value in computed, data, passing it as props, and directly referencing state, but it never seems to re-render despite the fact that the state I am checking for is changed to true. Currently, I am directly referencing the stor ...

JavaScript node failing to update variable value with promise value

I am facing an issue with the following code snippet- let { user } = req.body; let name = null; if (!user) { getStudent(id).then((x) => { user = x.user; name = x.name; }); } console.log(user, name); // prints undefined and null Despite us ...

What adjustments need to be made in order to enable image uploading using Selenium?

Scenario Currently, I am working on a project where I need to upload an image using Python and Selenium to the backend of a specific system. The HTML code for the upload button that receives the image file through the send_keys() method is as follows: & ...

Ideas for utilizing jQuery to extract data from CSS files

Hey there, I'm facing an issue on my HTML page where I have jQuery included. In my CSS file, I have quite a lot of lines and I'm trying to figure out how to read all styles for a specific element from the external CSS file rather than the inline ...

Trouble getting CSS and Javascript to bind when dynamically appending HTML elements

Attempting to dynamically bind HTML from an Angular controller SkillsApp.controller('homeController', function ($scope, $http, $q, $timeout) { $scope.getAllCategories = function () { $http({ url: "/Categories/GetAllCategories", ...

Why am I not seeing my views when trying to export them from a file in my routes folder?

I've been tinkering around with basic routing in ExpressJS and up to this point, I have implemented two routes: app.get('/', function(req,res) { res.render('index'); }); app.get('/pics', function(req,res) { res.rend ...

Accessing a webpage's 'object' using Javascript

There is a webpage I came across with a wealth of data that needs to be documented. And like any regular individual, I’d prefer not to do it manually. Therefore, I was wondering if there is a way to ‘import’ a webpage ‘object’ that could provide ...

Perform a JSON query using JavaScript

Is there a way to query JSON using JavaScript? In my JavaScript code, I have a JSON stored in a variable called 'json'. This JSON is an array of data, each containing 3 attributes: 'name', 'city', and 'age'. I am in ...

Selenium encountering issues with launching the Chrome browser

Here is a simple code snippet that I am experimenting with in Selenium: public static void main(String[] args) { // TODO Auto-generated method stub System.setProperty("webdriver.chrome.driver", "//Users//Downloads//chromedri ...

What is the best way to enable file downloads upon clicking on links using node.js?

I'm really struggling with my Node project. My goal is to create a web server that can display files in the current directory as clickable links for users to download. However, every time I make a request, the list of files keeps updating and display ...

Leveraging the "dialogclose" event within jQuery Mobile

Is there a way to change an image once it is clicked and change back when the dialog it links to is closed? I found a potential solution on this site, but after modifying it for my needs, it doesn't seem to work. Can anyone help me figure out what I a ...

Convert all page links to post requests instead

Currently, I am working on a JavaScript project where my objective is to transform all links on the page into forms. This will enable the requests to be sent using the POST method rather than the GET method. The code I have implemented so far is as follow ...