Steps :
1. First Navigate to any site.
2. Initialise action class and pass driver instance.
3. Find a new link and save as web element type
4.Mouse hover on that link and right click and open in another tab.
Sample Program :
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
public class NewTabOperation {
public static void main(String[] args) {
DesiredCapabilities capability = DesiredCapabilities.firefox();
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
Actions act = new Actions(driver);
WebElement newlink = driver.findElement(By.id("id"));
act.moveToElement(newlink ).contextClick().sendKeys("T").perform();
}
}
1. First Navigate to any site.
2. Initialise action class and pass driver instance.
3. Find a new link and save as web element type
4.Mouse hover on that link and right click and open in another tab.
Sample Program :
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
public class NewTabOperation {
public static void main(String[] args) {
DesiredCapabilities capability = DesiredCapabilities.firefox();
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
Actions act = new Actions(driver);
WebElement newlink = driver.findElement(By.id("id"));
act.moveToElement(newlink ).contextClick().sendKeys("T").perform();
}
}