赛普拉斯无法识别测试用例

时间:2020-10-08 14:40:35

标签: cypress

我使用赛普拉斯来测试可编程逻辑控制器的人机界面(HMI)。这些测试非常基础,主要包括点击事件和拦截与route2的网络通信。

当我运行测试时,尽管确实有命令,但是cypress经常无法识别一个或多个测试用例,并指出错误“未发出命令”。

那是柏树的问题吗?

编辑:

我没有更改默认配置,只是激活了实验性网络存根以使用route2。

我的测试用例非常相似,如下所示:

it('example testcase', function(){
    //intercept network communication
    route2('POST','http://localhost/WriteTag', (req) => {
        req.reply()
        const request =JSON.parse(req.body)
        req.body = JSON.stringify(request)
        expect(req.body).to.contain('Some Value')
    })

    //Get button and click
    cy.get('#someID').click()
})

HMI自动生成的代码:

<!DOCTYPE html>
<html class=" -moz-">
<head>
//couple of Scripts
</head>
<body id="proconweb_body">
   <div id="proconweb_mainarea" class="non-printable">
     <div id="box" style=[...]>
        </div><div id="StartLayoutbild" pweb-name="StartLayoutbild" pweb-type="gtiPicture" style=[...]>
          <div id="f4f64dbc-1fd6-4ae3-9e00-2e271e65580f" pweb-name="MainContainer" pweb-type="gtiContainer" style=[...]>
             <div class="carousel transition" style="white-space: nowrap; left: 0px;">        
               <div id="BildNr1" pweb-name="BildNr1" pweb-type="gtiPicture" style="left: 0px; top: 0px; position: relative; width: 1080px; height: 720px; padding: 0px; overflow: hidden; background-color: rgb(255, 255, 255); transform-origin: 0% 0% 0px; white-space: normal; margin-right: 0px; margin-bottom: 0px;" type="picture">

                <div id="fa1d2617-f2bf-4855-ade3-373b56c8518f" pweb-name="btLogVar1" pweb-type="gtiButton" pweb-style="common" style="left: 101px; top: 62px; position: absolute; width: 86px; height: 44px; box-sizing: border-box; overflow: hidden; white-space: nowrap; cursor: pointer;" common="" state="" class="ie_workaround"><div><div style="position: relative;"><div style="width: 84px; height: 42px; overflow: hidden; position: relative; box-sizing: border-box; display: table-cell; text-align: center; vertical-align: middle;"><div>LogVar1</div></div></div></div></div><!--btLogVar1-->
                <div id="70db24ce-b219-4dec-b231-50305ad3a6f7" pweb-name="BooleanDigitLogVar1" pweb-type="gtiTagDisplay" style="left: 211px; top: 69px; position: absolute; width: 15px; height: 31px; overflow: hidden; font-family: Arial; font-size: 27px; font-weight: bold; font-style: normal; color: rgb(0, 0, 0);"><div spellcheck="false" class="textArea" style="width: 15px; max-width: 15px; height: 31px; text-align: right; padding-right: 0px; padding-top: 0px; white-space: pre;">0</div></div><!--BooleanDigitLogVar1-->

                //more elements with the same structure

                </div>
              </div>
            <!--MainContainer-->
          </div>
         </div>
       <div> class "non-printable pictureLoadArea"</div>
       <div class="printable"></div><input type="file" style="display: none;">
    </body>
    </html>

0 个答案:

没有答案