Is there a way to close a tab in WebDriver or Protractor?

后端 未结 8 1280
悲&欢浪女
悲&欢浪女 2020-12-01 06:37

Is there a way to physically close a tab via Protractor or WebDriver?

I ask because while I know how to switch tabs programmatically, but it does not bring the acti

8条回答
  •  忘掉有多难
    2020-12-01 06:45

    I am using the command below to close the current tab after opening the link in new tab

    Instance.Driver2.SwitchTo().Window(Instance.Driver2.WindowHandles[1]).Close();
    

    Then, you can switch to the last tab by issue the command:

    Instance.Driver2.SwitchTo().Window(Instance.Driver2.WindowHandles[0]);
    

提交回复
热议问题