Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to execute a functional test using Selenium 2 and PHPUnit.

In the class 'Selenium2TestCase.php', I found this code:

class PHPUnit_Extensions_Selenium2TestCase_SessionCommand_Click extends PHPUnit_Extensions_Selenium2TestCase_Command
    const LEFT = 0;
    const MIDDLE = 1;
    const RIGHT = 2;

    public function __construct($argument, PHPUnit_Extensions_Selenium2TestCase_URL $url)
        if (is_null($argument)) {
            $jsonParameters = NULL;
        } elseif (!is_scalar($argument) || !in_array($argument, array(
            self::LEFT, self::RIGHT, self::MIDDLE
        ))) {
            throw new BadMethodCallException('Wrong parameter for click(): expecting 0, 1 or 2.');
        } else {
            $jsonParameters = array('button' => $argument);

        parent::__construct($jsonParameters, $url);

    public function httpMethod()
        return 'POST';

But I don't know how to use it to simulate a right click.

share|improve this question
any answer pleas – Lorina Jul 31 '13 at 14:30
public function testItemClick() {

    $element = $this->byCssSelector('blabla');

share|improve this answer

The php-webdriver project on GitHub has a function contextClick() which fires a right click.

share|improve this answer

You can use contextMenu method:



share|improve this answer
This is for the old Selenium RC, this does not work in the latest webdriver, I think. – Niels van Reijmersdal Mar 12 '14 at 21:12
thx Niels, I updated the answer with link to newest release. – rukbat Mar 13 '14 at 13:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.