selenium切换frame与跳出frame

切换至 frame 中

已知有 iframe 其 id 是 frame1,我们想切换其中来操纵其中的元素

frame() 目前接受的参数有第几个 frame,frame 的名字或 id,frame 定位的元素

在这里插入图片描述

public final By frameBy = By.id("frame1");

WebElement frameElement = driver.findElement(frameBy);
driver.switchTo().frame(frameElement);

切换至父 frame

driver.switchTo().parentFrame();

跳出 frame

跳出 frame 即返回原来的上下文环境

driver.switchTo().defaultContent();

猜你喜欢

转载自blog.csdn.net/abcnull/article/details/107592421
今日推荐