Error encountered while executing Selenium Web Driver's executeScript method: [JavascriptError: missing ) after argument list] with name: 'JavascriptError'

return driver.executeScript("\
    console.log('Error: Incorrect selection');\
    $('option:selected', 'select[name='who']').removeAttr('selected');\
    $('select[name='who']').find('option[value='2']').attr('selected',true);\
")

An issue occurs when trying to select an option using the selector provided. It throws an error and displays the following message:

{ [JavascriptError: missing ) after argument list] name: 'JavascriptError' }

Answer №1

The issue lies within statements such as

$('option:selected', 'select[name='who']')

Ensure you properly close the quotes that you open, as it can lead to confusion in this situation. It is recommended to use something like:

$("option:selected", "select[name='who']")

The same applies for the following statement; make sure to include single quotes inside double quotes or vice versa and avoid using the same type of quotes both inside and outside.

I noticed that you are already using double quotes for the entire string, so you might also consider:

$('option:selected', 'select[name=who]')

which means removing the single quotes from parts like select[name='who'] and utilizing them without quotes like select[name=who]

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

Error: An issue occurred with the tasks in the Gruntfile.js file

pm WARN EPACKAGEJSON <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="74041506001a1106041b0600151834445a445a44">[email protected]</a> No description npm WARN EPACKAGEJSON <a href="/cdn-cgi/l/email-protection" ...

An error occurred when attempting to make an HTTP POST request to /session with the following parameters: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY" using Selenium and PHPUnit

While running all tests using PHPUnit, I've set up a wrapper that initiates an instance of Apache, then launches the Selenium standalone server, followed by creating the Chrome Remote Webdriver instance at http://localhost:4444/wd/hub. This process ru ...

Uncaught TypeError: path.resolve was expected to be a function in Node.js

As a newbie in Node.js, I am currently following a tutorial. Although I have written the syntax correctly, I keep encountering a TypeError on path.revole(). I have also implemented the use of async/await. My intention was to send a POST request to the se ...

What to do when IE6/IE7 margins disappear after moving a relatively positioned floated div using jQuery's .hover()?

Sharing my code with you: http://jsbin.com/uhera3/edit Encountered an issue where the relatively positioned floated divs move to the left in IE7 when using jQuery's .hover() function. Any insights on how to resolve this problem? ...

I am experiencing an issue with my Node.js query, as it is not successfully adding a user to my database using

I'm currently working on developing an API using Node.JS, express, and MySQL with the Sequelize ORM. I wanted to do this project properly without relying on the CLI for every task. However, I've encountered a problem where my API fails to create ...

Creating a dynamic image slider that smoothly glides across a webpage

I've been working on a carousel (image slider) for my website and I need some help. Specifically, I want to reposition the entire slider slightly to the left on the webpage. You can see the slider in action on this site: and I also created a jsfiddle ...

Node.js Named Function to Escape the Callback Abyss is experiencing technical difficulties

I've been trying to tackle the issue of callback hell by utilizing the named function technique, but unfortunately, the callbacks are not functioning as expected. Instead, an error message saying TypeError: callback is not a function keeps appearing. ...

I'm looking to implement a feature in my notes application built with the MERN stack using Mongoose for MongoDB that allows users to add hidden notes. How

I am looking to implement a hidden notes functionality in my web application. When the "hide note" button is clicked, I want the note to be removed from its current location and added to a hidden notes section. Users should then have the ability to view an ...

Leverage the Express JS .all() function to identify the specific HTTP method that was utilized

My next task involves creating an endpoint at /api that will blindly proxy requests and responses to a legacy RESTful API system built in Ruby and hosted on a different domain. This is just a temporary step to transition smoothly, so it needs to work seam ...

Node.js ACL system centered around connections

In my Node.js project, I am working on setting up a permission framework using Sequelize as an ORM with Postgres. Despite conducting extensive research, the closest solution I have found utilizing existing npm modules is by implementing acl combined with a ...

Attempting to extract the host and protocol using node.js url.parse results in both values returning as

I'm just starting my journey with node.js. I read on https://www.npmjs.org/package/url that url_parts should contain the keys host and protocol. However, both are returning null for me. Any idea why? Here is how I am calling the server: http://localh ...

Enhance your webpack bundling with react and express

I have a React app running on an Express server and bundled with webpack. My problem is that every time I restart the server to make changes, it takes a long time to rebuild the frontend bundle even if I haven't made any changes to the frontend code. ...

An error occured upon loading FullCalendar: Uncaught TypeError - Unable to read property 'push' as it is undefined

First of all, thank you for your assistance. I've been trying to load FullCalendar (https://fullcalendar.io/) on my development environments but it doesn't seem to be working. When I check the console in Chrome, it shows me the following error m ...

Python - Retrieving Required Text from a <td class = "text">Grab This Information</td>

Being a beginner in using selenium and python, my main objective is to retrieve the revenue value for a specific company from the Hoovers website. Here's my current code: company = 'Trelleborg' page = 'https://hoovers.com/company-info ...

Discovering the top method to locate an Error Modal Message using Selenium

I am looking to automate a specific process that involves an Error modal popping up. I am trying to use Selenium to capture this modal which appears in multiple instances. So far, I have attempted to locate it by XPath without success. Using CSS selector o ...

Node.js is not compatible with npm

After installing Node on my machine and having everything work correctly, I encountered an issue during an online course back in 2019. The instructor was using an older version of npm (v5.5.1) and recommended that everyone downgrade to the same version for ...

Is it possible to use Beautiful Soup to locate elements only partially?

During my attempt to parse content using Beautiful Soup, I encountered an issue. The specific link in question is: The information I am trying to extract from the site is at this location: https://i.stack.imgur.com/pEZHp.png Upon examining the HTML stru ...

Having trouble integrating Socket.io with Express.js?

I'm currently attempting to connect socket.io with express.js: var socket = require('./socket_chat/socket.js'); var express = require('express'), app = module.exports.app = express(); var io = require('socket.io&apo ...

Adding additional parameters to route handlers in Express

I'm new to using Express and I'm interested in finding a way to increase the reusability of routes. In my application, I anticipate having numerous routes that can be handled by a common function but with different templates. For example: app.g ...

Ajax mode in Mvcpaging is malfunctioning

Having some trouble with getting MvcPaging to work in Ajax mode. It seems that it's not behaving as expected - instead of making an Ajax call, it's doing a full GET request. When checking the controller code, I noticed that Request.IsAjaxRequest( ...