Tuesday 7 January 2014

How to switch between frames

70. How to switch between frames?

WebDriver's driver.switchTo().frame() method takes one of the three possible arguments:
·         A number.
Select a frame by its (zero-based) index. That is, if a page has three frames, the first frame would be at index "0", the second at index "1" and the third at index "2". Once the frame has been selected, all subsequent calls on the WebDriver interface are made to that frame.
·         A name or ID.
Select a frame by its name or ID. Frames located by matching name attributes are always given precedence over those matched by ID.
Select a frame using its previously located WebElement.
Get the frame by it's id/name or locate it by driver.findElement() and you'll be good.



2 comments:

  1. hi ,
    say suppose, u have 40 frames in a page. and how do i fetch the index of a particular frame

    ReplyDelete
  2. i need some more clearly.please can u elaborate

    ReplyDelete