我需要捕获输入字段的警告消息,但我的逻辑无法创建场景

I need to capture the warning message for input field but my logic is not able to create the scenario

我需要捕获输入字段的强制警告消息,我的场景是

  1. 我必须点击输入字段
  2. 我需要输入数据
  3. 我必须再次清除输入数据

预期:它应该显示强制警告消息

实际:但未显示警告消息

但我观察到,在手动时间,在输入字段上执行操作时焦点没有移动。但是当我清除文本时,字段中的焦点丢失了。这是否会影响场景?

代码:

   await po.name().click();
   await po.name().clear();
   browser.sleep(3000);
   await po.name().sendKeys("saas");
   await po.name().clear();
   browser.sleep(3000);
   expect(po.msg().isDisplayed()).to.be.true;

有人可以帮助我吗?

也许试试这个:

po.name().sendKeys("s");
po.name().sendKeys(protractor.Key.BACK_SPACE);

试试下面的

   await po.name().click();
   await po.name().clear();
   browser.sleep(3000);
   await po.name().sendKeys("saas");
   await browser.actions().keyDown(protractor.Key.BACKSPACE).perform();
   browser.sleep(3000);
   expect(po.msg().isDisplayed()).to.be.true;