Unable to find element inside an Iframe

Hi All,

Why this is unable to find element. this element is inside an Iframe….

My code is below…


 
package Simple;
import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.testng.annotations.Test;
public class Trial {

WebDriver d;

@Test()
public void check() throws InterruptedException

{

d = new FirefoxDriver();

d.get("http://www.timesjobs.com/");

d.findElement(By.linkText("Sign In")).click();

Thread.sleep(20000);

d.switchTo().frame("GB_frame1");

d.findElement(By.cssSelector("#j_username")).sendKeys("snpanigrahi9@gmail.com");
}
}

Train Asked on November 19, 2014 in Selenium WebDriver.

Give us the screenshot of the Iframe and the html of the page, please always try to provide the comeplete information with your question.

Regards,
Lakshay Sharma

on November 20, 2014.

Hey its so simple….do one thing just find that sign in element using xpath or linktext whtever n store that as webElement just check out below code

WebElement iframe=d.findElement(By.here use any value in dat iframe ,so dat u can catch that frame)
d.switchto().Frame(iframe);
next find element n click on the elment ok…see below

d.findElement(By.linkText(“Sign In”).click();
Thats it

still any doubt post again vl help u

on November 22, 2014.
Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.