With example below, we will click on the link in a <li> element that contains "inanzzz" as text.

HTML li menu

<ul class="nav">
<li><a href="http://www.google.com">google</a></li>
<li><a href="http://www.inanzzz.com">inanzzz</a></li>
<li><a href="http://www.hello.com">hello</a></li>
<li><a href="http://www.world.com">world</a></li>

Feature file

Feature: Test feature

Scenario: Scenario description
Given I am on "/"
Then the response status code should be 200
And I click li option "inanzzz"
Then I should see "Behat"


use Behat\MinkExtension\Context\MinkContext;

class FeatureContext extends MinkContext
* @When /^I click li option "([^"]*)"$/
* @param $text
* @throws \InvalidArgumentException
public function iClickLiOption($text)
$session = $this->getSession();
$element = $session->getPage()->find(
$session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]')

if (null === $element) {
throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text));