1

I am trying to automate logging into http://wallethub.com/ using selenium java code. After clicking on Sign in link, a modal popup comes up with an iframe containing username and password fields, however I am not able to find the username field using following selenium code.

WebDriver d = new FirefoxDriver();
d.get("http://wallethub.com/profile/test_insurance_company/");
WebElement signIn = d.findElement(By.linkText("Sign In"));
signIn.click();

WebElement frame = d.findElement(By.tagName("iframe"));

WebDriver.TargetLocator locator =  d.switchTo();
WebDriver frameDriver = locator.frame(frame);
WebElement active = locator.activeElement();
frameDriver.findElement(By.id("overlay-username")).sendKeys(user);

My code dies on the last line saying cannot find "overlay-username" field, however I have verified , this field exists in firebug console.

This is on linux.

Any help will be appreciated.

1
  • Are you sure you have the correct iframe? Common mistake I make when I just inspect the element and follow the breadcrumbs and don't bother looking at the source. Commented Nov 14, 2013 at 4:51

1 Answer 1

1

As @Keikoku assumed you are working with the wrong iframe. There is also GoogleTagManger included in the page. If you check frame.getAttribute("src") you'll see https://apis.google.com/....

You can select the correct IFrame with this selector:

frame = driver.findElement(By.cssSelector("#wh-overlay-frame-inside iframe"));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.