Can nightwatchjs be used to retrieve values from multiple inputs simultaneously?
I am looking to verify the values of several input fields at once.
Your help is much appreciated.
Can nightwatchjs be used to retrieve values from multiple inputs simultaneously?
I am looking to verify the values of several input fields at once.
Your help is much appreciated.
Indeed, multiple input values can be retrieved:
The first option involves using callback methods (not recommended):
var text, text2, text3; // ...
browser.getValue('#inputField1', function (result) {
text = result.value;
browser.getValue('#inputField2', function (result) {
text2 = result.value;
browser.getValue('#inputField3', function (result) {
text3 = result.value;
browser.getValue('#inputField4' + text3, function (result) {
console.log(text, text2, text3) // your code
});
});
});
});
Alternatively, you can utilize the perform() API from the document (recommended):
var text, text2, text3;
browser
.getValue('#input', function (result) {
text = result.value;
browser.getValue('#inputField2', function (result) {
text2 = result.value;
});
})
.perform(function () {
browser.getValue('#inputField3', function (result) {
console.log(text2, text 1) // they do exist here
text3 = result.value;
});
});
For more information, refer to Nightwatch's documentation on Perform
To retrieve text or values, you can utilize either the getText or getValue method as shown in the following examples:
this.demoTest = function (browser) {
browser.getText("#main ul li a.first", function(result) {
this.assert.equal(typeof result, "object");
this.assert.equal(result.status, 0);
this.assert.equal(result.value, "nightwatchjs.org");
});
};
this.demoTest = function (browser) {
browser.getValue("form.login input[type=text]", function(result) {
this.assert.equal(typeof result, "object");
this.assert.equal(result.status, 0);
this.assert.equal(result.value, "enter username");
});
};
For more information on these methods, refer to the API documentation:Text API reference
My form initiates a GET request to the server upon loading, receiving data that is stored in 'master' and then copied to 'local' as shown below. $scope.dirty = false; init(data); function init(data) { $scope.master = angular.copy ...
I am currently restructuring our code base to incorporate promises. Below are two blocks of sample code: user.service.js export function updateUserProfileByUsername(req, res) { userController.getUserByUsername(req.params.username) .then((userProfile ...
In my AngularJS application, I have a checkbox that acts as a filter: Here is the data being used: app.controller('listdata', function($scope, $http) { $scope.users = [{ "name": "pravin", "queue": [{ "number": "456", "st ...
Recently, I encountered an issue with my Next.js frontend application that fetches data from a Strapi backend. Despite seeing requests being made in the Strapi developer logs, the retrieved data is empty. Below is a snippet of my Next.js code: import { us ...
Here is the code I am currently using to increment the value of intVariable using window.setInterval. var Arrow = (function () { function Arrow() { this.intVariable = 1; this.itemId = -1; this.interval = 25; } Arrow.p ...
Having trouble entering text into the email field on . I tried using WebDriverWait but it didn't work. Any help is appreciated. import time import datetime import random from selenium.webdriver.chrome.options import Options from selenium import webdri ...
My attempt to use selenium with geckodriver in headless mode within a docker container running Ubuntu 18.04 has hit a snag. Here is the code I am working with: while True: driver.execute_script("window.scrollTo(0, document.body.scrollHeight);" ...
I'm currently in the process of customizing my own version of "checkboxes" by styling label elements and moving the actual checkbox off-screen. This is the approach I decided to take based on the design and functionality requirements presented to me. ...
When attempting to click the element within the iframe in the RedBus web application, I encountered a Selenium timeout error stating "no such frame element". I have tried switching frames using id, name, and index but none of them were successful. WebDri ...
Within my VUE application, I've implemented a range slider component that allows users to view different values as they drag the slider. Everything seems to be functioning correctly, but I've encountered an issue where the mobile version of the p ...
I am currently utilizing jQuery's .animate() feature to create a smooth animation effect on the width of a <div> element when a child <input> is in focus. Nevertheless, I'm encountering an issue where the input field jumps up and down ...
I am faced with a challenging task of assigning an id field to objects within an array that has infinite levels. The rule is simple - for every level, the ID should correspond to the level number starting from 1. { "name": "Anything2&quo ...
Is it possible to validate a phone number in jQuery using preg_match? I have tried the following code without success: if (!preg_match("/^[0-9]{3}-|\s[0-9]{3}-|\s[0-9]{4}$/", phone.val() )) { phone.addClass("needsfille ...
I have created a photo gallery using a JSViews template which includes upvote and downvote buttons. When these buttons are clicked, it triggers a database update to increase the score. However, I am facing an issue with updating the Score field in the HTML ...
I am looking to enhance the functionality of my left menu buttons by adding a navigation path to each one (excluding the main menu). The menu items' names are received as @Input. I have set up a dictionary mapping all the items' names to their r ...
Looking for help with JavaScript: "a a a a".replace(/(^|\s)a(\s|$)/g, '$1') I thought the result would be '', but it's showing 'a a' instead. Can someone explain what I'm missing? To clarify, I want to r ...
Could you please explain why my JavaScript code isn't functioning as expected? The intended behavior is for the 'mark' div to move to the current mouse coordinates upon clicking within the map. ...
I recently integrated a mobile hamburger menu into my website, which is primarily built around a single page. However, I noticed that whenever I open the menu, it automatically scrolls to the top of the page regardless of where you were previously scrollin ...
Currently, I am diving into Typescript and VueJS, where I encountered an issue with pushing elements to my array. It seems to constantly override the 'name' property. Let me share the code snippet causing this problem: const itemsSelectedOptions ...
After following the instructions on deploying test-bot on IBM Watson from this link https://github.com/eciggaar/text-bot, I encountered errors while attempting to deploy the code locally using CLI foundry. My setup includes Node.js version 6.10.3 and npm ...