Selenium in C# - How do I navigate different frames

前端 未结 2 623
伪装坚强ぢ
伪装坚强ぢ 2020-12-22 11:35

The website has the following elements:

\"html\"

It has 3 different frames, how do I navigate myself to the

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-22 12:22

    You can actually select an iFrame using the below methods: -

    • frame(index)
    • frame(Name of Frame [or] Id of the frame)

    • frame(WebElement frameElement)

    • defaultContent()

    So you can switch by passing the any above information about the frame. Yes you need to switch everytime according to require action

    As we can see your frame have different name like :- top, navigation etc. Use name of the frame to switch between them

    Example:-

    driver.SwitchTo().Frame("top");
    

    .... Perform your action on frame

    driver.SwitchTo().defaultContent();
    
    driver.SwitchTo().Frame("navigation");
    

    .... Perform your action on frame

    driver.SwitchTo().defaultContent();
    

    Hope it will help you :)

提交回复
热议问题