Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Right Click with Nightwatch

I am trying to test my GUI with Nightwatch. I can not seem to find how to simulate a right click. I went through the API Reference page(http://nightwatchjs.org/api) and searched everywhere. Am I missing something here? Because I believe that right clicking should be one of the most basic functionalities.

like image 972
lamyarus Avatar asked Feb 11 '23 16:02

lamyarus


2 Answers

Good news !!!

Since Nightwatch.js v0.6.13, you can fire a real right click :-)

"Right Click to Show ContextMenu" : function (browser) {
  browser
   .moveToElement('#targetElement')
   .mouseButtonClick('right')
   .pause(5000)
   .end();
}
like image 152
Nicolas Pennec Avatar answered Feb 13 '23 07:02

Nicolas Pennec


EDIT: This DOESN'T WORK. I am going to leave it here anyways. It might be helpful somehow.

I found a work around. mousebuttonDown() method allows the use of left, middle and right clicks. They are assigned 0,1 and 2 respectively. So the following somehow simulates a rightclick:


"Right Click to Show ContextMenu" : function (browser) {
    browser
       .moveToElement(/*locate your element here*/)
       .mouseButtonDown(2)
       .mouseButtonUp(2)
       .end();
}
like image 44
lamyarus Avatar answered Feb 13 '23 07:02

lamyarus