如何使用Selenium WebDriver在新选项卡(chrome)中打开链接?
2022-09-02 02:08:09
System.setProperty("webdriver.chrome.driver", "D:\\softwares\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("https://mail.google.com/");
String selectLinkOpeninNewTab = Keys.chord(Keys.CONTROL,Keys.RETURN);
driver.findElement(By.linkText("www.facebook.com")).sendKeys(selectLinkOpeninNewTab);
新选项卡正在打开,但 URL 链接未打开。