0

I am trying to include some Javascript commands in Selenium webdriver (Java language) and the Javascript part does not execute, no errors in logs, compiles normally, just doesn't execute.

Here is my JS piece of code:

import org.openqa.selenium.JavascriptExecutor;
   if (driver instanceof JavascriptExecutor) {
             ((JavascriptExecutor)driver).executeScript("javaScriptCode();");
             }

         if (driver instanceof JavascriptExecutor) {
             ((JavascriptExecutor)driver).executeScript("window.open();");
             }

         ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles());
         driver.switchTo().window(tabs.get(0)); 

It is meant to open a new tab and switch to it, I have tried different piece of codes to do the same function and it still does not execute.
Any idea on how to solve this?

unno
  • 47
  • 1
  • 9

0 Answers0