Kartik R
Kartik R

Reputation: 31

how to press Enter key in Behat

I am new to behat and I am stuck in a place where I need to enter texts in a field and then I have to hit enter to add the item to the list.

I am not able to find a solution in Behat. Please help if anyone know about this?

Upvotes: 2

Views: 2068

Answers (2)

Kartik R
Kartik R

Reputation: 31

Sorry I found the solution in mink document which is quite straightforward. So the answer is:

$this->getSession()
      ->getPage()
      ->findById($id_of_field)
      ->keyPress($unicode_of_the_key);

Upvotes: 1

timiTao
timiTao

Reputation: 1413

If i'm correct, you are using extension mink for that?

In that case, you need to checkout documentation.

One of examples:

$this->getMinkContext()->pressButton('myid');

if you're using others library, the show composer.json and behat.yml files - this should help find solution.

Upvotes: 0

Related Questions