Search code examples
phpphpunittostringbehat

Behat: having method __toString() not implemented error


I have php 5.6.14.

Writing context for behat tests I saw an error:error

/** @When /^I want to see JS alert$/ */
public function iExecuteJs() {
    $this->webDriver()->executeScript("jsAlert()");
        if ($this->webDriver()->switchTo()->alert()->getText().contains("js")){
            echo "test passed";
        };

}

What should I do with it?

Thanks


Solution

  • Finally, I changed the code like:

        $element = $this->webDriver()->switchTo()->alert()->getText();
            if ($element == "I am a JS Alert"){
               echo "correct js alert appeared";
            }