Unleashing the Power of Puppeteer: Setting Input Element Values in REACT and Typescript

I am looking to test my app using Puppeteer. My app was built with REACT and TypeScript. How can I properly set the input? Please refer to the 2 attachments.

I have attempted the following approaches, but have not been successful:

1. Attempt:

await page.waitForSelector('#MuiButtonBase-root');
// await page.select('#MuiTouchRipple-root');
await page.waitForSelector('#name');
await page.type('#name', 'Hello');

2. Attempt:

await page.$eval('#MuiDialogContent-root input:MuiFormControl-root:nth-child(1)', el => el.value = 'Hello');  

Answer â„–1

Incorrect selector alert! Instead of using #name, try [id="name"]. The correct one is [name="name"]

Remember to use the first method for React to ensure the onChange event is triggered.

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

Testing RESTful APIs in Node.js

Currently, I am conducting a testing project utilizing the Jasmine framework in Node.js. For the client code, I performed unit tests by mocking with $httpBackend. Now, my focus is on testing the server-side code and REST APIs. However, I am unsure of the ...

Steps for customizing ngxdatatable with modal dialog in Angular 2

My Objective I have a collection of office names and departments in my ngxdatatable. Each office name is accompanied by an edit and delete button, allowing users to modify or remove the respective office name/department. Specifically for editing purposes ...

Why Compiling Angular 1.x Templates with Jasmine is Failing to Validate Data Output

Attempting to perform unit testing on an HTML template containing variables in paragraph, anchor tags, and {{header.title || translate}}. Despite multiple attempts, the posts tried do not seem to work. The retrieved HTML template remains unchanged when com ...

What is the best method to include spacing between strings in an array and then combine them into a csv-friendly format?

The method I am currently employing involves the following: var authorsNameList = authors.map(x => x.FirstName + ' ' + x.LastName); Yet, this generates an outcome similar to this: Bob Smith,Bill Jones,Nancy Smith Nevertheless, the desired ...

Oops! The testing has encountered a problem: "Yam" is not defined

I encountered an issue while unit testing an application and I could use some help. Below is the problem along with a code snippet. This particular code snippet is responsible for displaying a yammer window. The variable yam is declared outside the compo ...

Is there a way to omit the 'src' directory from the typescript compilation output?

Is there a way to exclude the root src folder when using tsc? My current configuration has the output directory set to target, but instead of getting target/src/file.ts, I want it to be just target/file.ts. ...

The challenge of resizing dialog elements in Angular Material

I am currently working on developing a text dialog for my app that will be reused frequently. The text dialog consists of a header, a message displayed above the text input, the text input area, and "Ok" and "Cancel" buttons. Upon my observation, I have f ...

Manipulating variables in a page from a different page in Angular 7: How to control a variable in dashboard.page.ts from landing-in.page.ts

Hey, I'm a newcomer to Angular 7 and Ionic 4. How can I manage variables on the dashboard page from another page? I attempted a simple logic in my application by controlling tbFor with the setToolbar function at dashboard.page.ts from landing-in.page ...

What is the best way to refresh a Component upon sending data to the server?

I'm in the process of developing a cross-platform application. I have a TabView Component that needs to update a tab after sending data to the server. During the initialization (ngOnInit) phase, I dynamically set the content of my tab. However, when I ...

A guide to implementing includes() and indexOf() in Vuetify

Struggling with a code snippet in vuetify, facing issues: <template> ..... {{ countf(options[1], options[2], options[3], options[4], options[5]) }} ...... </template> <script lang="ts"> export default Vue.extend({ data () ...

Issues with React and Typescript testing arise from a type error stating "Failed to convert type 'Global & typeof globalThis' to type 'GlobalWithFetchMock'..."

Working with React and Typescript is an exhilarating experience, but it can sometimes lead to perplexing challenges. Recently, all my tests started failing due to a recurring error associated with jest-fetch-mock: > NODE_ENV=test jest FAIL src/store/i ...

Utilizing useClass in Angular's APP_INITIALIZER

Before my application starts up, I require some API data and am currently handling it with APP_INITIALIZER and useFactory. However, I aim to enhance the structure by separating all the code from app.module.ts: app.module.ts import { NgModule} from '@ ...

What is the best way to establish a universal stylesheet for mutual scss variables in a Nx React endeavor?

Seeking some guidance here as I embark on a new project. My goal is to set up a basic Nx workspace with a TypeScript React frontend and utilize SCSS styles. Here's how the project's architecture is laid out: root/ ├─ apps/ ├─ libs/ │ â ...

Utilizing NgModelGroup nesting in various components for improved data management

Whenever I attempt to nest NgModelGroup inside another NgModelGroup, Angular seems to just ignore it. I'm currently utilizing Angular 12 and Template-driven Forms. Here is how my code appears: app.component.html <form #form="ngForm"> ...

The Nuxt Vuex authentication store seems to be having trouble updating my getters

Despite the store containing the data, my getters are not updating reactively. Take a look at my code below: function initialAuthState (): AuthState { return { token: undefined, currentUser: undefined, refreshToken: undefined } } export c ...

Design a versatile Form Input module with React and TypeScript for repeated use

Is it possible to define input attributes in typescript? I'm working with an AddUser Component and a TextInput Component. I'd like to incorporate the TextInput component within the AddUser component and then pass properties to the TextInput compo ...

Angular Dialog Component: Passing and Populating an Array with Mat-Dialog

Here's the situation: I will enter a value in the QTY text field. A Mat dialog will appear, showing how many quantities I have entered. My question is, how can I iterate an object or data in the afterclosed function and populate it to the setItem? Cur ...

How can I efficiently map an array based on multiple other arrays in JavaScript/TypeScript using ES6(7) without nested loops?

I am dealing with 2 arrays: const history = [ { type: 'change', old: 1, new: 2 }, { type: 'change', old: 3, new: 4 }, ]; const contents = [ { id: 1, info: 'infor1' }, { id: 2, info: 'infor2' }, { id: ...

Can you explain the distinction between 'bigint' in lowercase and 'BigInt'?

Currently, I am in the process of updating some TypeScript code that utilizes an external library for handling big numbers to BigInt (ES2020). However, the linter is throwing numerous errors which I find quite perplexing. https://i.sstatic.net/VnQSK.png ...

The Angular 13 application encounters a "moment is not a function" error after importing an Angular 13 package

Upgrading a private library named privLib to Angular 13 has been my recent task in order to facilitate the migration of all other projects. However, an issue arises when this library is imported into another project where one of the services utilizes momen ...