Testing 在TestCafe中上载文件时找不到元素

Testing 在TestCafe中上载文件时找不到元素,testing,file-upload,automation,e2e-testing,testcafe,Testing,File Upload,Automation,E2e Testing,Testcafe,在此处输入图像描述 我在下面写了代码 让browseButton=Wait Selector'input'。属性为'id','card_image_158311662160_11.707407693474106'; 等待 .单击选择器'.fa.fa图像' //上传img .setFilesToUploadbrowseButton,“../../artifacts/uploads/boba.jpg” 但结果是 1) The specified selector does not match any

在此处输入图像描述

我在下面写了代码

让browseButton=Wait Selector'input'。属性为'id','card_image_158311662160_11.707407693474106'; 等待 .单击选择器'.fa.fa图像' //上传img .setFilesToUploadbrowseButton,“../../artifacts/uploads/boba.jpg” 但结果是

1) The specified selector does not match any element in the DOM tree.

         | Selector('input')
       > |   .withAttribute('id', 'card_image_1583116662160_11.707407693474106')

看起来您正试图在选择器中使用动态ID。在这种情况下,您应该基于CSS类或其他非动态属性创建选择器。请参阅此文档部分:

以下示例可能也很有用:。该示例演示如何访问DOM属性,并使用可以调试的断言验证它们

如果还有什么不清楚的地方,请告诉我

更新:


更新2:-选择器“输入”。使用属性“id”,“card\u image\uw+/

是,我尝试让browseButton=等待选择器“输入”。使用属性“id”,“card\u image\uw+/”;但是仍然得到相同的结果,指定的选择器与DOM树中的任何元素都不匹配。您需要在正则表达式中使用斜杠::selector'input'。with attribute'id',/card\u image\uw+/;