Java 使用assert Station验证项目是否未添加到购物车,slenium

Java 使用assert Station验证项目是否未添加到购物车,slenium,java,selenium,Java,Selenium,我想使用assert语句验证项目是否未添加到购物车。这是我的selenium代码: public void verify_itemadded(String action) throws Exception { WebDriverWait wait = new WebDriverWait(session.driver, 40); switch(action) { case "added": case "not remov

我想使用assert语句验证项目是否未添加到购物车。这是我的selenium代码:

public void verify_itemadded(String action) throws Exception {
    WebDriverWait wait = new WebDriverWait(session.driver, 40);
    switch(action) {
        case "added":
        case "not removed":
            WebElement itemVerify = wait.until(ExpectedConditions.visibilityOf(element("ItemVerify")));
            Assert.assertTrue("Item displayed in card",itemVerify.isDisplayed());
            if (itemVerify.isDisplayed()) {
                logger.info("Item displayed in cart");
            }
            break;
        case "not added":
            WebElement itemVerifyremove = wait.until(ExpectedConditions.visibilityOf(element("ScanOrLookup")));
            Assert.assertTrue("Item not displayed in card",!itemVerifyremove.isDisplayed());
            if (!itemVerifyremove.isDisplayed()) {
                logger.info("Item not displayed in cart");
            }
            break;

    }
我得到一个错误,说“商品未显示在购物车中”,而它应该给出测试应该通过。
有人能告诉我哪里出了问题吗?谢谢:)

添加一个中断案例。同时打印并查看isDisplayed()打印的值。显然
itemVerifyremove.isDiaplayed()
is
false
,您需要找出此方法返回false的原因。