diff --git a/src/Concerns/MakesAssertions.php b/src/Concerns/MakesAssertions.php index 9d348586d..0ca2ff633 100644 --- a/src/Concerns/MakesAssertions.php +++ b/src/Concerns/MakesAssertions.php @@ -827,14 +827,11 @@ public function assertAttributeContains($selector, $attribute, $value) */ public function assertAttributeDoesntContain($selector, $attribute, $value) { - $fullSelector = $this->resolver->format($selector); - $actual = $this->resolver->findOrFail($selector)->getAttribute($attribute); - PHPUnit::assertNotNull( - $actual, - "Did not see expected attribute [{$attribute}] within element [{$fullSelector}]." - ); + if (is_null($actual)) { + return $this; + } PHPUnit::assertStringNotContainsString( $value, diff --git a/tests/Unit/MakesAssertionsTest.php b/tests/Unit/MakesAssertionsTest.php index 3160ffd43..ebea4026a 100644 --- a/tests/Unit/MakesAssertionsTest.php +++ b/tests/Unit/MakesAssertionsTest.php @@ -683,15 +683,7 @@ public function test_assert_attribute_does_not_contain() $browser->assertAttributeDoesntContain('foo', 'bar', 'class-c'); - try { - $browser->assertAttributeDoesntContain('foo', 'bar', 'class-c'); - $this->fail(); - } catch (ExpectationFailedException $e) { - $this->assertStringContainsString( - 'Did not see expected attribute [bar] within element [Foo].', - $e->getMessage() - ); - } + $browser->assertAttributeDoesntContain('foo', 'bar', 'class-c'); try { $browser->assertAttributeDoesntContain('foo', 'bar', 'class-1');