Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium webdriver 断言链中的最后一个断言失败-将以前传递的所有断言显示为失败_Selenium Webdriver_Automated Tests_Testng_Assertj - Fatal编程技术网

Selenium webdriver 断言链中的最后一个断言失败-将以前传递的所有断言显示为失败

Selenium webdriver 断言链中的最后一个断言失败-将以前传递的所有断言显示为失败,selenium-webdriver,automated-tests,testng,assertj,Selenium Webdriver,Automated Tests,Testng,Assertj,我有一个包含多个断言的方法,除了最后一个之外,所有的断言都在传递,它显示了所有的断言消息,即使它被传递了。 是否有人知道如何解决这种情况,以及如何在控制台中仅获取失败消息而不是所有消息 Assertions.assertThat(actual.getAttribute("id").isEqualTo("first_name"); Assertions.assertThat(actual.tagName()).isEqualTo("input"); Assertions.a

我有一个包含多个断言的方法,除了最后一个之外,所有的断言都在传递,它显示了所有的断言消息,即使它被传递了。 是否有人知道如何解决这种情况,以及如何在控制台中仅获取失败消息而不是所有消息

    Assertions.assertThat(actual.getAttribute("id").isEqualTo("first_name");
    Assertions.assertThat(actual.tagName()).isEqualTo("input");
    Assertions.assertThat(actual.getAttribute("class")).isEqualTo("input-group");
    Assertions.assertThat(actual.getText()).isEqualTo("John");
上面的代码是我写的,所有的条件都通过了,除了最后一个,但它显示如下所述

Expected actual to be first_name but got <first_name>

Expected actual to be input but got <input>

Expected actual to be input-group but got <input-group>

Expected actual to be Johny but got John

实际上,最后一条语句是失败的,但它显示了如上所述的所有消息,即使条件已通过。

如果您发布代码示例来重现问题,您将获得更好的帮助


您的代码包含键入错误,因为Assertj提供了一个isEqualTo,您使用的是isEqualTo。

您使用的是哪个断言框架?断言是您创建的自定义类吗?因为我们需要看到断言类我正在使用AssertJ-Fluent Asssertion API这是我的类定义使用AssertJ API公共类MyAssert扩展AbstractAssert已修复代码部分中的键入错误。谢谢你的建议!不幸的是,你没有提供足够的信息让人们能够提供帮助,提供一个可复制的测试用例,我相信你会得到帮助。我会给出代码,但我们公司的政策不允许透露。但我将和你们分享一个类似的例子,可能是下面的问题:MyAssert.assertThatactual.hasFirstNameSiddhant//将没有错误MyAssert.assertThatactual.hasLastNameChothe//将不会有错误MyAssert.assertThatactual.HasFullNamesIDhant//只有这样才会产生错误。但是MyAssert.assertThatactual.hasFirstNameSiddhant.hasLastNameChothe.hasFullNameSiddhant某物//将同时发出所有三条消息。我正在构建一个MessageComposer类,该类存在该错误。对于由此造成的不便,我深表歉意。[关闭]