Popup's in selenium webdrivers

前端 未结 3 2124
猫巷女王i
猫巷女王i 2020-11-27 05:01

So I\'m working with selenium firefox webdrivers in c# winform and I have this code below to get the handle of the popup that shows when you click on the \"webtraffic_popup_

3条回答
  •  暖寄归人
    2020-11-27 05:30

    If the lastly opened window is your target then simply do the following after the click

    driver.SwitchTo().Window(driver.WindowHandles.ToList().Last());
    

    EDIT

    //You may need to go back to parent window to perform additional actions;
    
    // to the new window
    driver.SwitchTo().Window(driver.WindowHandles.ToList().Last());
    
     // to the new window
    driver.SwitchTo().Window(driver.WindowHandles.ToList().First());
    //or
    driver.SwitchTo().DefaultContent();
    

提交回复
热议问题