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

Encountering a TypeError indicating that the asterisk is not functioning as a proper function

Whenever I run my server.js file, an error keeps popping up: TypeError: routing is not a function This occurs in the following line of code: routing(app); In my routing.js file, the content looks like this: // JavaScript source code var friends = requ ...

Is there a more efficient method for converting an array of objects?

Is there a more efficient way to change just one value in an array without iterating through every element? I've included the code below where I am trying to update the contact number for each user in an array. Although my current solution works, it ...

What is the process for incorporating buttons into an Angular mat-table?

I have successfully utilized Angular mat-table to showcase data retrieved from a database: view the image description here <table mat-table [dataSource]="UserDataSourceFilters" class="mat-elevation-z1 mt-5"> <ng-co ...

Divergence in results: discrepancy found in the outputs of nodejs crypto module and tweetnacl.js

Consider this code snippet in nodejs: import crypto from 'crypto'; const pkey = `-----BEGIN PRIVATE KEY----- MC4CAQAwBQYDK2VwBCIEIJC52rh4PVHgA/4p20mFhiaQ/iKtmr/XJWMtqAmdTaFw -----END PRIVATE KEY-----`; // placeholder key function sign_message(m ...

React component that enables radio inputs to repeat upon selection

My current project involves creating a quiz app where users can answer single questions using React on Codepen. I am utilizing an API to fetch a question, along with 3 incorrect answers and 1 correct answer, then storing them in the app's state. Howev ...

The "scrollTop" function seems to be malfunctioning in Firefox but works perfectly fine in Chrome. Is there a way to fix this issue?

Issue with scrollTop in Firefox jQuery(window).scroll(function(){ var NextScroll = jQuery(this).scrollTop(); if (NextScroll >= 800){ jQuery('#logomacchia').addClass("maccancello"); } else { jQuery('#logomacch ...

Path search for the location of the Selenium driver

I'm currently setting up selenium tests in nCrunch with the output of the tests going to a temporary folder specific to nCrunch. When I attempt to create the driver (new PhantomJSDriver()), I encounter the following error: OpenQA.Selenium.DriverSe ...

Generating a linked pledge with AngularJS

I need to create a linked commitment for my service provider: this.$get = function($q, $window, $rootScope) { var $facebook=$q.defer(); $rootScope.$on("fb.load", function(e, FB) { $facebook.resolve(FB); }); $facebook.api = functi ...

What is the best way to stylize a date using Bootstrap-datepicker?

While this topic is well-known, I have a slightly more complex question regarding it. I have gone through the documentation here. My goal is to display the date in French format (dd/mm/yyyy) and save the value in US format (yyyy-mm-dd). Additionally, I nee ...

Unable to send headers to the client in expressjs as they have already been set

After successfully logging in, I am trying to redirect to another page but keep encountering the error message "Cannot set headers after they are sent to the client". I understand that I need to place the res.redirect method somewhere else in my code, bu ...

Unable to retrieve an image from various sources

My setup includes an Express server with a designated folder for images. app.use(express.static("files")); When attempting to access an image from the "files" folder at localhost:3000/test, everything functions properly. However, when trying to ...

Ways to showcase multiple elements using introjs

I am attempting to highlight multiple DOM elements using the JS library intro.js, but I am encountering an issue. It seems that I can only define one element to be highlighted at a time. introjs.setOptions({ steps: [ { ...

"Discovering the most efficient method to retrieve a value from a dropdown in Selenium, especially when it

Choosing a Value from Input Dropdown Using Selenium Webdriver I have the XPath for the dropdown element, but I am having trouble selecting values from it. The HTML code for the dropdown is as follows: Available Values in the Dropdown: 06/29/2019 I nee ...

Tips for turning off cookies while using Selenium with Headless Chrome in RSpec

Scenario: Currently, I am in the process of creating automated tests for a Rails application using RSpec and Capybara. To simulate browser interactions, we are utilizing Selenium with Headless Chrome. Dilemma: I am trying to figure out how to disable co ...

Unveiling the method to fetch the emitted value from a child component and incorporate it into the parent component's return data in Vue

How can I retrieve the title value passed by the Topbar component and incorporate it into the data() return section? I attempted to create a method to pass the value, but was unsuccessful despite being able to successfully log the value in the parent file. ...

Database not receiving input data from AngularJS form submission

Having some trouble saving form data to the database using angularjs. Not sure what I'm doing wrong. Here's my HTML form: <form id="challenge_form" class="row" > <input type="text" placeholder="Challenge Name" ng-model="ch ...

Switch between different table rows

I have here a table that is used for displaying menu and submenu items. It's a mix of PHP (to fetch the menu items and their respective submenus) and HTML. What I am trying to figure out is how to toggle the visibility of only the submenu items under ...

Cease the execution within the promise.then block

Embarking on my nodejs journey has been an exciting experience. While I have a background in other programming languages, the concept of promises is new to me. In my nodejs environment, I am using expressjs + sequelize. I'm currently working on setti ...

Retrieve data from a local JSON file and showcase it in a list within a Next.js project. The error "Property 'data' does not exist on type String

Having trouble displaying the names of crates (which are filled with records/albums) from a local JSON file. The names aren't showing up and I'm wondering if I should be using params or if perhaps not stringifying the JSON would help. Visual Stud ...

Issue with date range filter functionality not functioning as expected

Struggling to get the date range filter to function properly. Selecting a date triggers it, but nothing is being added to the var filter. I've spent hours trying to solve this issue with no progress. html <div class="form-group"> <input ...