0

I want to emulate a middle button mouse click on a text URL on a page so it will open on a new tab, in Selenium coding in JavaScript.

For example:

await driver.get("https://google.com");

//thats the xpath for the 'terms' text url
await driver.findElement(By.xpath('/html/body/div[1]/div[5]/div[2]/div[2]/a[2]')).click();
Nicky
  • 3,607
  • 6
  • 33
  • 64
Adam Norman
  • 3
  • 1
  • 5

2 Answers2

0

here is some code that is not direct solution but might lead you to real solution look (How to detect middle mouse button click?)[here]

Alex
  • 44
  • 5
0

Ok I found a solution

I can just send 2 keys on the element which is ctrl & enter

 await driver.get("https://google.com");
 //thats the xpath for the 'terms' text URL
 await driver.findElement(By.xpath('/html/body/div[1]/div[5]/div[2]/div[2]/a[2]')).sendKeys(Key.CONTROL, Key.ENTER);
Adam Norman
  • 3
  • 1
  • 5