How do I simulate a right click using Selenium 2 and PHPUnit?



  • 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_finger:         ))) {
                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.



  • 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(...
    
    }
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2