1.Opening Browser
WebDriver driver=new FirefoxDriver();
2.Window Maximize
driver.manage().window().maximize();
3.Open URL
driver.get("https://mail.google.com/");
4.Navigate
driver.navigate().to("http://gmr-automation.blogspot.in/");
5.Back
driver.navigate().back();
6.Forward
driver.navigate().forward();
7.Refresh
driver.navigate().refresh();
8.Close the Browser
driver.close();
9.Quit The Browser
driver.quit();
10.Get Page Title
driver.getTitle();
11.Fetch current URL of The browser
driver.getCurrentUrl();
12.Fetch Entire page Source Code/HTML code
driver.getPageSource();
13.Get Current Window ID
driver.getWindowHandle();
14.Get All Windows ID's
Set<String> elements= driver.getWindowHandles();
15.Finding WEB Element
driver.findElement(By.id("value"));
driver.findElement(By.name("Locator value"));
driver.findElement(By.xpath("Locator value"));
driver.findElement(By.cssSelector("Locator value"));
driver.findElement(By.linkText("Locator value"));
driver.findElement(By.partialLinkText("Locator value"));
driver.findElement(By.className("Locator value"));
driver.findElement(By.tagName("Locator value"));
16.Click on Element
driver.findElement(By.id("value")).click();
17.Typing Text
driver.findElement(By.id("value")).sendKeys("GMR-AUTOMATION");
18.Fetching Element Text and Storing
String text =driver.findElement(By.id("value")).getText();
19. Normal Wait Statement
Thred.sleep(int number);
20.Implicit Wait statement
driver.manage().timeouts().implicitlyWait(mSeconds, TimeUnit.MILLISECONDS);
21.Explicit Wait Statement
WebDriverWait wait = new WebDriverWait(driver, Time in Seconds);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("locatorvalue"),"Messge"));
22.Setting Size of the Window
driver.manage().window().setSize(new Dimension(int number, int number));
23.Setting Position of the Window
driver.manage().window().setPosition(new Point(int x, int y));
24.Dragging element
WebElement src = driver.findElement(By.id("draggable"));
Actions actions=new Actions();
actions.dragAndDropBy(src, int xOffset, int yOffset).build() .perform();
25.Drag and Drop:
WebElement src = driver.findElement(By.id("draggable"));
WebElement dest = driver.findElement(By.id("droppable"));
new Actions(driver).dragAndDrop(src, dest).build().perform();
26.Drop Down Selecting
/*
* drop down select by visible text method
*/
Select select=new Select(dropdown element);
select.selectByVisibleText(visibleText);
/*
* drop down select by index method
*/
Select select=new Select(dropdown element);
select.selectByIndex(index);
/*
* drop down select by value method
*/
Select select=new Select(dropdown element);
select.selectByValue(value);
27.Drop Down Deselecting
/*
* drop down Dselect by visible text method
*/
Select select=new Select(dropdown element);
select.deselectByVisibleText(visibleText);
/*
* drop down Dselect by index method
*/
Select select=new Select(dropdown element);
select.deselectByIndex(index);
/*
* drop down Dselect by value method
*/
DSelect select=new Select(dropdown element);
select.deselectByValue(value);
28.Deselect all from drop down
Select select=new Select(dropdown element);
select.deselectAll();
29.Check For Multiselect
Select select=new Select(dropdown element);
select.isMultiple();
30.Mouse over to an element
Actions actions=new Actions(driver);
actions.moveToElement(WebElement e ).build().perform();
sample method:
public void moveToElement(WebElement e){
Actions actions=new Actions(driver);
actions.moveToElement(e).build().perform();
}
31.Right Click
Actions actions=new Actions(driver);
actions.contextClick(WebElemet e).build().perform();
sample:
public void rightclick(WebElement e) {
Actions actions=new Actions(driver);
actions.contextClick(e).build().perform();
}
32.Other Mouse Actions
These will be performed at the within the window
Actions actions=new Actions(driver);
actions.clickAndHold();
actions. release()
actions. doubleClick();
33.Other Mouse Actions On Element
Actions actions=new Actions(driver);
actions.clickAndHold(WebElement e);
actions. release(WebElement e)
actions. doubleClick(WebElement e);
34.Switching To Alert boxes
This will be continued up to ......
WebDriver driver=new FirefoxDriver();
2.Window Maximize
driver.manage().window().maximize();
3.Open URL
driver.get("https://mail.google.com/");
4.Navigate
driver.navigate().to("http://gmr-automation.blogspot.in/");
5.Back
driver.navigate().back();
6.Forward
driver.navigate().forward();
7.Refresh
driver.navigate().refresh();
8.Close the Browser
driver.close();
9.Quit The Browser
driver.quit();
10.Get Page Title
driver.getTitle();
11.Fetch current URL of The browser
driver.getCurrentUrl();
12.Fetch Entire page Source Code/HTML code
driver.getPageSource();
13.Get Current Window ID
driver.getWindowHandle();
14.Get All Windows ID's
Set<String> elements= driver.getWindowHandles();
15.Finding WEB Element
driver.findElement(By.id("value"));
driver.findElement(By.name("Locator value"));
driver.findElement(By.xpath("Locator value"));
driver.findElement(By.cssSelector("Locator value"));
driver.findElement(By.linkText("Locator value"));
driver.findElement(By.partialLinkText("Locator value"));
driver.findElement(By.className("Locator value"));
driver.findElement(By.tagName("Locator value"));
16.Click on Element
driver.findElement(By.id("value")).click();
17.Typing Text
driver.findElement(By.id("value")).sendKeys("GMR-AUTOMATION");
18.Fetching Element Text and Storing
String text =driver.findElement(By.id("value")).getText();
19. Normal Wait Statement
Thred.sleep(int number);
20.Implicit Wait statement
driver.manage().timeouts().implicitlyWait(mSeconds, TimeUnit.MILLISECONDS);
21.Explicit Wait Statement
WebDriverWait wait = new WebDriverWait(driver, Time in Seconds);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("locatorvalue"),"Messge"));
22.Setting Size of the Window
driver.manage().window().setSize(new Dimension(int number, int number));
23.Setting Position of the Window
driver.manage().window().setPosition(new Point(int x, int y));
24.Dragging element
WebElement src = driver.findElement(By.id("draggable"));
Actions actions=new Actions();
actions.dragAndDropBy(src, int xOffset, int yOffset).build() .perform();
25.Drag and Drop:
WebElement src = driver.findElement(By.id("draggable"));
WebElement dest = driver.findElement(By.id("droppable"));
new Actions(driver).dragAndDrop(src, dest).build().perform();
26.Drop Down Selecting
/*
* drop down select by visible text method
*/
Select select=new Select(dropdown element);
select.selectByVisibleText(visibleText);
/*
* drop down select by index method
*/
Select select=new Select(dropdown element);
select.selectByIndex(index);
/*
* drop down select by value method
*/
Select select=new Select(dropdown element);
select.selectByValue(value);
27.Drop Down Deselecting
/*
* drop down Dselect by visible text method
*/
Select select=new Select(dropdown element);
select.deselectByVisibleText(visibleText);
/*
* drop down Dselect by index method
*/
Select select=new Select(dropdown element);
select.deselectByIndex(index);
/*
* drop down Dselect by value method
*/
DSelect select=new Select(dropdown element);
select.deselectByValue(value);
28.Deselect all from drop down
Select select=new Select(dropdown element);
select.deselectAll();
29.Check For Multiselect
Select select=new Select(dropdown element);
select.isMultiple();
30.Mouse over to an element
Actions actions=new Actions(driver);
actions.moveToElement(WebElement e ).build().perform();
sample method:
public void moveToElement(WebElement e){
Actions actions=new Actions(driver);
actions.moveToElement(e).build().perform();
}
31.Right Click
Actions actions=new Actions(driver);
actions.contextClick(WebElemet e).build().perform();
sample:
public void rightclick(WebElement e) {
Actions actions=new Actions(driver);
actions.contextClick(e).build().perform();
}
32.Other Mouse Actions
These will be performed at the within the window
Actions actions=new Actions(driver);
actions.clickAndHold();
actions. release()
actions. doubleClick();
33.Other Mouse Actions On Element
Actions actions=new Actions(driver);
actions.clickAndHold(WebElement e);
actions. release(WebElement e)
actions. doubleClick(WebElement e);
34.Switching To Alert boxes
Alert alert = driver.switchTo().alert();
Alert is an Interface
35.Alert box accepting
Alert alert = driver.switchTo().alert();
alert.accept();
(or)
driver.switchTo().alert().accept();
36. Alert box closing
Alert alert = driver.switchTo().alert();
alert.dismiss();
(or)
driver.switchTo().alert().dismiss();
37.Typing Text in The Alert message Text boxes
Alert alert = driver.switchTo().alert();
clearing and typing
alert.clear();
alert.sendKeys("Message into The alert box");
(or)
driver.switchTo().alert().sendKeys("Message into The alert box");
38.Fetching alert Box Message and displaying
Alert alert = driver.switchTo().alert();
String text=alert.getText();
System.out.println("alert message"+text);
39.Text clearing in the text box/any
driver.findElement(By.id("value")).clear();
40.Switching Window
ON 2 Windows Opening
List<String> strings =(List<String>) driver.getWindowHandles();
String childWindowID=strings.get(0);
String parentWindowID=strings.get(1);
switching child window:
driver.switchTo().window(childWindowID);
switching parent window:
driver.switchTo().window(parentWindowID);
41.Screen Shot of web page
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("Path of the image"));
41.Screen Shot of web page
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("Path of the image"));
We have to use TakesScreenshot interface for taking screen shot of the page as shown bellow.
Here the path of the image we can give like this "C:\\Users\\Public\\Pictures\\gmr-automation.png"
Here gmr-automation.png image will be created in that place
Here the path of the image we can give like this "C:\\Users\\Public\\Pictures\\gmr-automation.png"
Here gmr-automation.png image will be created in that place
No comments:
Post a Comment