Handling frame in Selenium(WebDriver) - Bug Reaper

                  Bug Reaper

Lean about Automation Testing,Selenium WebDriver,RestAssured,Appium,Jenkins,JAVA,API Automation,TestNG,Maven, Rest API, SOAP API,Linux,Maven,Security Testing,Interview Questions

Monday 23 September 2013

Handling frame in Selenium(WebDriver)

Snippet for Handling  frame in selenium


WebElement frame1=driver.findElement(By.className("codtnbiframepd"));
driver.switchTo().frame(frame1);
driver.findElement(By.id("txtcode")).sendKeys("121008");
driver.findElement(By.id("btnfind")).click();

By Index
By Name or Id
By Web Element
Switch to the frame by index:


To Switch to default frame

driver.switchTo().defaultContent(); Index is one of the attributes for the Iframe through which we can switch to it.

Index of the iframe starts with '0'.

Suppose if there are 100 frames in page, we can switch to the iframe by using index.

driver.switchTo().frame(0);
driver.switchTo().frame(1);
Switch to the frame by Name or ID:


Name and ID are attributes of iframe through which we can switch to the it

No comments:

Post a Comment