且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何遍历iFrame中的不同帧?

更新时间:2023-09-01 11:29:04

切换h到任何框架元素,只需使用 driver.switchTo()。frame(framename);

switch to any frame element , just use driver.switchTo().frame("framename");

一次我们切换到一帧,如果我们需要切换到另一帧,我们必须切换到父帧。为此使用

Once we switched to one frame, if we need to switch to another frame, we have to switch to the parent frame.For that use

driver.switchTo().parentFrame();

如果使用 driver.switchTo()。defaultContent(); ,它可能无效。
所以去 driver.switchTo()。parentFrame(); ,它工作正常。

If you use driver.switchTo().defaultContent();, it may not work. so go for driver.switchTo().parentFrame();, it works fine.