简体   繁体   English

如何将 html 元素定位器中的日期字符串与 javascript 连接起来

[英]how to concatenate a date string inside an html element locator with javascript

I have the following line of code in a playwright test using js我在使用 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

To concatenate a string use +要连接字符串,请使用+

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM