-2

I have this piece of code:

 ((JavascriptExecutor)driver).executeScript("Object.assign(document.createElement('a'), { target: '_blank', href: 'https://facebook.com'}).click()");

       ((JavascriptExecutor)driver).executeScript("window.open('https://google.com')'");

First command is meant to create a new tab and open facebook.com and it does, first is meant to open google.com but nothing happens, am I doing anything wrong?

Disclaimer:
1.I am not familiar with Javascript at all, this is a Java Selenium project (hence why the (JavascriptExecutor)driver).executeScript part and I need to use Javascript for these few lines.
2.I tried multiple simpler piece of codes instead of this one but nothing worked hence why I ended up with this which is not the simplest.

unno
  • 47
  • 1
  • 9

1 Answers1

0

you have extra single quotation in your second line.

you should write ((JavascriptExecutor)driver).executeScript("window.open('https://google.com')");