Home > other >  how to concatenate a date string inside an html element locator with javascript
how to concatenate a date string inside an html element locator with javascript

Time:03-09

I have the following line of code in a playwright test using js

await page.click('[aria-label="Choose Friday, March 4th, 2022"]');

I want to store the date inside a variable like this:

let date = "Friday, March 4th, 2022";

which I have as

await page.click('[aria-label="Choose 'date' "]');

however in my editor I see the warning

',' expected

CodePudding user response:

To concatenate a string use

await page.click('[aria-label="Choose '   date   ' "]');
  • Related