Encountering issues with the setValue function in Nightwatch

Currently, I am in the process of setting up a new Nightwatch project to automate a basic Google search page. The assertion for searchbox present on page is successful, but I am facing difficulties performing any mouse or keyboard actions on the elements (SearchBox, or SearchButton)

Please note: The version of Nightwatch being used is 1.0.

Test case:

module.exports = {
  before : function(browser) {
   browser.globals.waitForConditionTimeout = 5000;
  },
    tags: ['google'],
    'Demo test Google' : function (browser) {
         browser 
         .url('http://www.google.com') // Navigate to URL
         .waitForElementVisible('body', 10000) // Wait for page to load
         .pause(2000)
         .assert.title('Google') // Confirm site title matches
         .assert.visible('input[name=q]') 
         .setValue('input[name=q]', 'nightwatchjs') // Enter values
         .click('button[name=btnG]') // Click on search box
         .pause(1000)
         .end()
       },
};

I have also attempted the following approach:

var setValue =  function(sel, value) {
  $(sel).val(value).change();
};
module.exports = {
  before : function(browser) {
       browser.globals.waitForConditionTimeout = 5000;
  },
    tags: ['google'],
    'Demo test Google' : function (browser) {
         browser 
         .url('http://www.google.com') // Navigate to URL
         .waitForElementVisible('body', 10000) // Wait for page to load
         .pause(2000)
         .assert.title('Google') // Confirm site title matches
         .assert.visible('input[name=q]') 
         .execute(setValue, ['input[name=q]', 'nightwatchjs'])
         .click('button[name=btnG]') // Click on search box
         .pause(1000)
         .end()
       },
};

Below is the output log:

[Google] Test Suite

Running: Demo test Google

  • √ Element was visible after 133 milliseconds.
  • √ Testing if the page title equals "Google" - 18 ms.
  • √ Testing if element is visible - 61 ms.

Error log:

Error encountered while running .setElementValue() protocol action: unknown error: call function result missing 'value'

TimeoutError: An issue arose while executing the .setValue() command on : {"status":-1, "state":"", "value": {"message":"unknown error: call function result missing 'value'", "error":[" (Session info: chrome=77.0.3865.120)"," (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.17763 x86_64)"]},"errorStatus":13,"error":"unknown error: call function result missing 'value'","httpStatusCode":200} at process._tickCallback (internal/process/next_tick.js:68:7) NoSuchElementError: A problem occurred during the execution of the .click() command on : at process._tickCallback (internal/process/next_tick.js:68:7)

Answer №1

It can be beneficial to click on the input first before using setValue(). Give it a try!

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

Exploring the power of Foundation For Apps and Angular by seamlessly displaying dynamic data sourced from

I'm currently working with Foundation for Apps, a framework that incorporates elements of AngularJS. My goal is to display the content from a local JSON file by accessing it through a controller and rendering the results as 'cards'. Addition ...

Alter the Cascading Style Sheets (CSS) value by accessing a

I have two files, keyboard.css and keyboard.js. My objective is to modify a CSS rule: .ui-keyboard div { font-size: 1.1em; } Is there an alternative method to change the font size without utilizing $(".ui-keyboard div").css()? I want the modification ...

Issue with npm installation leading to missing node_modules directory

When attempting to run npm install . in a local directory, I keep encountering the following errors: npm ERR! install Couldn't read dependencies npm ERR! Darwin 15.2.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "." npm ERR! no ...

Setting up the configuration for a Selenium node-hubStateToProps

I have a specific setup in my /etc/rc.local file that includes running Xvfb and launching a Selenium server on specified ports. Xvfb :99 -screen 0 1024x768x24 -ac 2>&1 >/dev/null & export DISPLAY=:99 java -jar /home/ubuntu/selenium-server-st ...

Preventing the callback nightmare in nodeJs / Sharing variables with nested functions

Let's simplify this scenario: const generateUrl = (req, res) => { const id = req.query.someParameter; const query = MyMongooseModel.findOne({'id': id}); query.exec((err, mongooseModel) => { if(err) { / ...

Mastering the art of integrating a multi-step form in React

While developing a multi-step form in my React 17.0.1 application using Typescript version 4.1.2, I came across this helpful guide: https://dev.to/sametweb/how-to-create-multi-step-forms-in-react-3km4 The guide was clear up to step 6, which I decided to s ...

Behat Mink: dispatch a key stroke to the element in focus

I am looking to verify if the tab key navigation is functioning properly on my system. Here is the snippet of code I am using: define('TAB_CHARCODE', 9); define('NO_MODIFIER', ''); // .... $this->getSession()->getPage() ...

Choose your location with React: Country -> Province/State -> City?

It seems to be a common need for people to have a feature where selecting a country would then filter down the provinces or states available for that country, and then from there, narrow down to city selections. I've been searching NPM for a solution, ...

What is the process for setting up a subrouter using React Router v6?

This is the current React Router setup I am using: const router = createBrowserRouter([ { path: "/", element: ( <Page activeNav="home" > <Home /> </Page> ) }, { ...

What is the best way to allow someone to chain callback methods on my custom jQuery plugin?

My goal is to enhance the functionality of jQuery.post() by implementing a way to check the response from the server and trigger different callbacks based on that response. For instance: $("#frmFoo").postForm("ajax") .start(function () { showSpinner( ...

How can I create an input field that only reveals something when a specific code is entered?

I am currently developing a website using HTML, and I would like to create an admin section that requires a password input in order to access. After consulting resources on w3schools, I attempted the following code: <button onclick="checkPassword()" i ...

What sets apart window.app=new Vue({}) versus const app = new Vue({}) when included in app.js within a Vue.js environment?

What exactly is the difference between using window.app and const app in main.js within Vue? import question from './components/Questions.vue'; Vue.http.headers.common['X-CSRF-TOKEN'] = window.Laravel.csrfToken; window.App = new Vue({ ...

How can we organize and display the data from two linked arrays, one containing player names and the other containing

Looking for help on how to rank 3 players based on their scores using arrays. I've hit a roadblock and need guidance! Here's a brief example: Player 1 : Taylor Score Taylor : 15 Player 2 : Jordan Score Jordan : 20 Player 3 : Alex Score Alex : ...

Utilizing Jquery to enhance slide image transitions with navigational links

As a newcomer to jQuery, I am attempting to create a slider using jQuery. Here is the script I have so far: $(function() { var bgCounter = 0, text = [ 'some html code here', 'some html code here', 'some ...

I am seeking the original XML element with the exact tagName, including proper case sensitivity

Below is a code snippet that retrieves and displays the UpperCase text of tagNames. I am looking to work with the original case. var xml = '<myElements type="AA" coID="A923"><myHouse>01</myHouse> <myCars>02</myCars><m ...

Using C# Selenium WebDriver to interact with JavaScriptExecutor for handling prompt windows

I am faced with a JavaScript Prompt Window that I need to handle. Previously, I was able to manage a simple prompt with only an 'OK' and 'Cancel' button using the following code: ((IJavaScriptExecutor)ts.getDriver()).ExecuteScript("win ...

Pass data that has been asynchronously resolved from the parent component to the child component using props in Vue

Main component: <template> <div> <Nav :data="data" /> </div> </template> <script lang="ts"> // ... imports removed for clarity @Component({ components: { Nav: () => import('@/components/Nav.vue&ap ...

Converting an array of objects into a flat array of objects with Javascript

My data array requires conversion to a flattened array returning new header and data. For instance, the first object contains a name with three data points: "title, first, last." The desired output is: From : { gender: 'male', name: { ...

The functionality to apply a color class to a navbar item when clicked is malfunctioning

I'm attempting to create a navigation bar using text that toggles the visibility of different divs. I want the selected option to appear in red, indicating it has been chosen, while deselecting any other options. I am new to JavaScript and thought add ...

Updating WordPress div content based on selected post type using dropdown menu

I am in the process of developing a WordPress plugin that will generate a custom post type and widget for users to add to their websites. The goal is to have the widget display a dropdown select box with titles of each post, and when a title is selected, t ...