package com.switchto.test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import utility.Helper;
public class FrameDemo {
public static void main(String[] args) throws Exception{
WebDriver driver = Helper.launchBrowser("chrome");
Thread.sleep(5000);
//Using frame(int index) and index starts from 0 but for Internet Explorer index starts with 1
driver.switchTo().frame(0);
driver.findElement(By.linkText("LEARN HTML")).click();
Thread.sleep(3000);
//Before switching to other frame you have to switch to default page
driver.switchTo().defaultContent();
//Using frame(String frameName) name attribute of iframe or frame tag.
driver.switchTo().frame("frame2");
driver.findElement(By.linkText("Projects")).click();
Thread.sleep(3000);
driver.switchTo().defaultContent();
//partialLinkText locator is like contains method of String class
driver.findElement(By.partialLinkText("Goo")).click();
Thread.sleep(3000);
driver.navigate().back();
Thread.sleep(5000);
driver.close();
}
}
No comments:
Post a Comment