I have write function with assertTrue in page file and i used that function on DuskTestCase.
class MyPage extends Page
{
public function validation(Browser $browser){
$browser ->clickLink('Sources') ;
$this->assertTrue(count($browser->driver->findElements(WebDriverBy::xpath('//*[@id="home"]'))) > 0);
}
}
class MyTest extends DuskTestCase
{
public function test001() {
$this->browse(function (Browser $browser) {
$browser->visit(new MyPage)
->validation();
});
}
}
Error: Call to undefined method TestsBrowserPagesMyPage::assertTrue()
Can anyone help me?
Thank you.
Hi there,
Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:
However, this issue will not be locked and everyone is still free to discuss solutions to your problem!
Thanks.
Use static assertions:
use PHPUnit\Framework\Assert;
class MyPage extends Page
{
public function validation(Browser $browser)
{
$browser ->clickLink('Sources');
Assert::assertTrue(count($browser->driver->findElements(WebDriverBy::xpath('//*[@id="home"]'))) > 0);
}
}
Thank you @staudenmeir. it is working now
Most helpful comment
Use static assertions: