Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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
add comment

3 Answers

public function testItemClick() {

    $this->url($this->pageUrl);
    sleep(2);
    $element = $this->byCssSelector('blabla');
    $this->moveto($element);
    $this->click(PHPUnit_Extensions_Selenium2TestCase_SessionCommand_Click::RIGHT);
    $this->assertStringStartsWith(...

}
share|improve this answer
add comment

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

share|improve this answer
add comment

You can use contextMenu method:

$this->contextMenu(//table[@id='yourID']);

See http://release.seleniumhq.org/selenium-core/1.0.1/reference.html#contextMenu

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 at 21:12
    
thx Niels, I updated the answer with link to newest release. –  rukbat Mar 13 at 13:16
add comment

Your Answer

 
discard

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.