How to select an item from “context list Menu” - p

2019-06-09 13:06发布

问题:

Here is the link of the question I had asked earlier, but the thread was inactive for quick a while, so asking the question fresh again.

Question: I can right click on an element but unable to select an item from the "Context List menu"(the one without a DOM). When I press "ARROW_DOWN" thrice the actual page moves down, instead of the selection on the Context menu. I researched a bit but no luck.

My guess is that the context menu is not focused, but not 100% sure. I tried to take a snapshot once I Right Clicked, and the snapshot doesn't contain the "Context menu".

Code to Right Click element and press down Arrow keys:

browser.actions().click(elementVariable).perform();

browser.actions().click(protractor.Button.RIGHT).sendKeys(protractor.Key.ARROW_DOWN).sendKeys(protractor.Key.ARROW_DOWN).sendKeys(protractor.Key.ARROW_DOWN).perform();

Code for taking snapshot:

browser.actions().click(elementVariable).perform();
    browser.actions().click(protractor.Button.RIGHT).perform()
     .then(function() {
         browser.takeScreenshot().then(function(screenShot) {
            writeScreenShot(screenShot, "image.png");
    });
    });

    //writeScreenShot takes two variables actual screenshot data and the file name. And the screenshot is saved as "image.png

Kindly let me know:

  1. How can I select an item from the "context menu" list?
  2. Why the "ARROW_DOWN" happening on the browser instead of the context menu list?
  3. what is the reason that the context menu isn't visible in the snapshot?