How to switch between frames in Selenium WebDriver using Java

后端 未结 7 1785
轮回少年
轮回少年 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 14:05

    There is also possibility to use WebDriverWait with ExpectedConditions (to make sure that Frame will be available).

    1. With string as parameter

      (new WebDriverWait(driver, 5)).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("frame-name"));
      
    2. With locator as a parameter

      (new WebDriverWait(driver, 5)).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("frame-id")));
      

    More info can be found here

提交回复
热议问题