/* Script Summary
Title : Webdriver Script062 : Opening New Tab
Author : QA Masterz
Actions :
1. Set the Base URL to "http://qamasterz.blogspot.in/".
2. Use Keys to Open New Tab
*/
package com.qamasterz.webdriver.junit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
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.Keys;
public class s062_TabbedBrowsing {
// Declaring variable 'webDriver' of WebDriver Type
WebDriver webDriver;
// Declaring baseURL variable of String Type
String baseUrl;
@Before
public void startUp() throws Exception {
// Initializing FireFox Driver
webDriver = new FirefoxDriver();
// Assigning URL to variable 'baseUrl'
baseUrl = "http://qamasterz.blogspot.in";
}
@Test
public void tests062_TabbedBrowsing() throws Exception {
// Open the link
webDriver.get(baseUrl);
// Maximize browser window
webDriver.manage().window().maximize();
// Store the Body Tag
WebElement body = webDriver.findElement(By.tagName("body"));
// Press CTRL + T Key for New Tab
body.sendKeys(Keys.chord(Keys.CONTROL, "t"));
// Wait for 5 Seconds
Thread.sleep(5000);
}
@After
public void shutDown() throws Exception {
// This will close the browser
webDriver.quit();
}
}
Title : Webdriver Script062 : Opening New Tab
Author : QA Masterz
Actions :
1. Set the Base URL to "http://qamasterz.blogspot.in/".
2. Use Keys to Open New Tab
*/
package com.qamasterz.webdriver.junit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
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.Keys;
public class s062_TabbedBrowsing {
// Declaring variable 'webDriver' of WebDriver Type
WebDriver webDriver;
// Declaring baseURL variable of String Type
String baseUrl;
@Before
public void startUp() throws Exception {
// Initializing FireFox Driver
webDriver = new FirefoxDriver();
// Assigning URL to variable 'baseUrl'
baseUrl = "http://qamasterz.blogspot.in";
}
@Test
public void tests062_TabbedBrowsing() throws Exception {
// Open the link
webDriver.get(baseUrl);
// Maximize browser window
webDriver.manage().window().maximize();
// Store the Body Tag
WebElement body = webDriver.findElement(By.tagName("body"));
// Press CTRL + T Key for New Tab
body.sendKeys(Keys.chord(Keys.CONTROL, "t"));
// Wait for 5 Seconds
Thread.sleep(5000);
}
@After
public void shutDown() throws Exception {
// This will close the browser
webDriver.quit();
}
}