@@ -416,4 +416,48 @@ public function testSeeAttribute(): void
416416 $ this ->assertTrue ($ dom ->see (null , '*[ name = user ] ' ));
417417 $ this ->assertFalse ($ dom ->see (null , '*[ name = notthere ] ' ));
418418 }
419+
420+ public function testSeeXPathSuccess (): void
421+ {
422+ $ dom = new DOMParser ();
423+
424+ $ html = '<html><body><h1 class="heading gap-2">Hello World Wide Web</h1></body></html> ' ;
425+ $ dom ->withString ($ html );
426+
427+ $ this ->assertTrue ($ dom ->seeXPath ('//h1[contains(@class, "heading")] ' ));
428+ $ this ->assertTrue ($ dom ->seeXPath ('//h1[contains(@class, "heading")][contains(.,"Hello World")] ' ));
429+ }
430+
431+ public function testSeeXPathFail (): void
432+ {
433+ $ dom = new DOMParser ();
434+
435+ $ html = '<html><body><h1 class="heading gap-2">Hello World Wide Web</h1></body></html> ' ;
436+ $ dom ->withString ($ html );
437+
438+ $ this ->assertFalse ($ dom ->seeXPath ('//h1[contains(@class, "heading123")] ' ));
439+ $ this ->assertFalse ($ dom ->seeXPath ('//h1[contains(@class, "heading")][contains(.,"Hello World 123")] ' ));
440+ }
441+
442+ public function testDontSeeXPathSuccess (): void
443+ {
444+ $ dom = new DOMParser ();
445+
446+ $ html = '<html><body><h1 class="heading gap-2">Hello World Wide Web</h1></body></html> ' ;
447+ $ dom ->withString ($ html );
448+
449+ $ this ->assertTrue ($ dom ->dontSeeXPath ('//h1[contains(@class, "heading123")] ' ));
450+ $ this ->assertTrue ($ dom ->dontSeeXPath ('//h1[contains(@class, "heading")][contains(.,"Hello World 123")] ' ));
451+ }
452+
453+ public function testDontSeeXPathFail (): void
454+ {
455+ $ dom = new DOMParser ();
456+
457+ $ html = '<html><body><h1 class="heading gap-2">Hello World Wide Web</h1></body></html> ' ;
458+ $ dom ->withString ($ html );
459+
460+ $ this ->assertFalse ($ dom ->dontSeeXPath ('//h1[contains(@class, "heading")] ' ));
461+ $ this ->assertFalse ($ dom ->dontSeeXPath ('//h1[contains(@class, "heading")][contains(.,"Hello World")] ' ));
462+ }
419463}
0 commit comments