Tuesday, January 22, 2013

Finding elements within iframe using firebug


Firebug Tip

Firebug command line allows executing JavaScript expressions within context of the current page. Firebug also provides a set of built in APIs and one of them is cd().

Lets consider below iframe

                <iframe id="testID" name="testName" src="iframe.html" />


  • cd(document.getElementById("testID").contentWindow); switch to a frame by ID
  • cd(window.frames[0]); switch to the first frame in the list of frames
  • cd(window.frames["testName"]); switch to a frame using by name
  • cd(window.top); switching back to the top level window


Happy Coding .. :)


Regards,
SantoshSarma

1 comment:

  1. I am referring ur blog this is very helpful for me...

    http://stackoverflow.com/questions/12729265/switch-tabs-using-selenium-webdriver

    above given link is very useful for me but in ur answer second statement is not working i dont know why...

    new Actions(driver).sendKeys(driver.findElement(By.tagName("html")), Keys.CONTROL).sendKeys(driver.findElement(By.tagName("html")),Keys.NUMPAD1).build().perform();

    what should i do for going back to my old tab.

    Thanks n Best regards
    pritam Gupta

    pritam.jec58@gmail.com

    ReplyDelete

Note: Only a member of this blog may post a comment.