How to switch between frames in Selenium WebDriver using Java

后端 未结 7 1798
轮回少年
轮回少年 2020-11-22 13:31

I am using java with WebDriver.I have to switch between two frames. I have recorded the test case in selenium IDE and in that I got the values as selectFrame relative=top se

7条回答
  •  遥遥无期
    2020-11-22 13:55

    First you have to locate the frame id and define it in a WebElement

    For ex:- WebElement fr = driver.findElementById("id");

    Then switch to the frame using this code:- driver.switchTo().frame("Frame_ID");

    An example script:-

    WebElement fr = driver.findElementById("theIframe");
    
    driver.switchTo().frame(fr);
    
    Then to move out of frame use:- driver.switchTo().defaultContent();
    

提交回复
热议问题