WebDriver driver = new ChromeDriver();
JavascriptExecutor jse = (JavascriptExecutor)driver;
1.直接传入JavaScript代码
jse.executeScript("window.open(‘" + String.format(detailsUrl,urlParam[0],urlParam[1],urlParam[2],urlParam[4],urlParam[3] ) + "‘)");
2.传入WebElement执行JS
WebElement webElement = webDriver.findElement(By.id("tab_2"));
jse.executeScript("arguments[0].click();", webElement);
时间: 2024-10-05 22:07:02