title: Trying to automate a right-click and choose the first option "Open the link in a new tab"
body: <pre><code>public void openNewEbay() throws InterruptedException {
      // to click on open link on new tab
      Actions rightclick = new Actions(driver);
      WebElement elementlocator = driver
              .findElement(By.xpath("//li[@class='hl-cat-nav__js-tab']//a[contains(text(),'Electronics')]"));
  
      //rightclick.contextClick(elementlocator).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.RETURN).build().perform();
      Thread.sleep(3000);
      rightclick.contextClick(elementlocator).build().perform();
      Thread.sleep(5000);
      rightclick.sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.RETURN).build().perform();
  
      rightclick.sendKeys(Keys.RETURN).build().perform();
  
      /*ArrayList tab = new ArrayList(driver.getWindowHandles());
      System.out.println(tab.size());*/
  }
  
  public void openNewEbay() throws InterruptedException {
      // to click on open link on new tab
      Actions rightclick = new Actions(driver);
      WebElement elementlocator = driver
              .findElement(By.xpath("//li[@class='hl-cat-nav__js-tab']//a[contains(text(),'Electronics')]"));
  
      //rightclick.contextClick(elementlocator).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.RETURN).build().perform();
      Thread.sleep(3000);
      rightclick.contextClick(elementlocator).build().perform();
      Thread.sleep(5000);
      rightclick.sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.RETURN).build().perform();
  
      rightclick.sendKeys(Keys.RETURN).build().perform();
  
      /*ArrayList tab = new ArrayList(driver.getWindowHandles());
      System.out.println(tab.size());*/
  }
  </code></pre>
  
  <p>Selenium-code issue: trying to automate right click but when I right click, it  does not move to right-click options instead it clicks on elements. I want to select the option "Open the link on new tab"</p>