Home >Java >javaTutorial >How to Open a New Tab in Firefox using Selenium WebDriver in Java?

How to Open a New Tab in Firefox using Selenium WebDriver in Java?

Susan Sarandon
Susan SarandonOriginal
2024-12-12 16:46:101041browse

How to Open a New Tab in Firefox using Selenium WebDriver in Java?

Opening New Tabs in Firefox Using Selenium WebDriver in Java

In Selenium WebDriver for Java, you can open a new tab in an existing Firefox browser by manipulating the body element:

WebDriver driver = new FirefoxDriver();
driver.get("http://stackoverflow.com/");

WebElement body = driver.findElement(By.tagName("body"));
body.sendKeys(Keys.CONTROL + "t");

driver.quit();

This action sends the "control t" key combination to the browser, which opens a new tab.

The above is the detailed content of How to Open a New Tab in Firefox using Selenium WebDriver in Java?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn