Selenium WebDriver で複数のフレームを小さなコードで処理する方法を教えてください。
11809 次
3 に答える
0
WebDriver では 1 フレーム内でしか検索できません。別のフレームの要素とやり取りするには、それに「切り替える」必要があります。次に、ドライバーはそのコンテキストをそのフレームにシフトし、その中で作業できるようになります。
小さなコードで
完了したら、次を使用してメイン ウィンドウに戻ります。
driver.switchTo().defaultContent();
また、より多くのドキュメント。
于 2013-07-20T14:53:26.187 に答える
0
public void switchToFrame(String ParentFrame, String ChildFrame) {
try {
driver.switchTo().frame(ParentFrame).switchTo().frame(ChildFrame);
System.out.println("Navigated to inner frame with id " + ChildFrame
+ "which is present on frame with id" + ParentFrame);
}
catch (NoSuchFrameException e) {
System.out.println("Unable to locate frame with id " +ParentFrame + " or "
+ ChildFrame + e.getStackTrace());
} catch (Exception e) {
System.out.println("Unable to navigate to inner frame with id "
+ ChildFrame + "which is present on frame with id"
+ ParentFrame + e.getStackTrace());
}
}
于 2020-03-13T11:15:44.997 に答える