mardi 18 juin 2019

how to click a button under a nested div using xpath and class in behat3

I have a nested div structure with a button element in it. I want to check the click and redirect functionality on it via behat test cases, But I am not able to test it as error shows up.

Have tried the following

This is my step in feature file

And I click on button "cmd_btn_submit"

and my context file has

     * @And I click on button :arg1
     * @Then I click on button :arg1
     */
    public function iClickOnButton($arg1)
    {
       $this->getSession()->getPage()->find("xpath", "//button[div[@id='divSubmit1'][contains(text(),'".$arg1."')]]
")->click();

}

Getting this error,

And I click on button "cmd_btn_submit"                                                                                   # Shop\Features\Context\FeatureContext::iClickOnButton()
      Fatal error: Call to a member function click() on null (Behat\Testwork\Call\Exception\FatalThrowableError)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire