简体   繁体   English

使用Selenium在IE11中关闭第n个打开的窗口

[英]Close nth open window in IE11 using Selenium

On the page " http://www.seleniumframework.com/Practiceform/ " There is a button "New Message Window". 在页面“ http://www.seleniumframework.com/Practiceform/ ”有一个按钮“新消息窗口”。

I want to hit this button 5 times which will open 5 windows. 我想点击这个按钮5次,这将打开5个窗口。 All the windows have same content. 所有窗口都有相同的内容。 So cant identify specific window using content 因此无法使用内容识别特定窗口

i want to close the 3rd window. 我想关闭第3个窗口。

I'm only seeing this open the same window multiple times. 我只是看到它多次打开同一个窗口。 However, if you want to do this, you would: 但是,如果你想这样做,你会:

  1. Get the current window handles 获取当前窗口句柄
  2. Switch to the third one 切换到第三个
  3. Send your webdriver instance the close command (not the quit command, that will close all windows) 向webdriver实例发送close命令(不是quit命令,将关闭所有窗口)

Without knowing what language you're using, I won't be able to give you an example. 如果不知道你正在使用什么语言,我将无法给你一个例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM