English 中文(简体)
2. 窗口所有权而不在 se网络用户中转换
原标题:Get title of window without switching in selenium webdriver

是否有办法获得窗口所有权,而不在 se中作出任何转换?

目前使用以下代码的Im:

public boolean switchToWindowByTitle(String title){
    String currentWindow = driver.getWindowHandle(); 
    Set<String> availableWindows = driver.getWindowHandles(); 
    if (!availableWindows.isEmpty()) { 
         for (String windowId : availableWindows) {
              String switchedWindowTitle=driver.switchTo().window(windowId).getTitle();
              if ((switchedWindowTitle.equals(title))||(switchedWindowTitle.contains(title))){ 
                  return true; 
              } else { 
                driver.switchTo().window(currentWindow); 
              } 
          } 
     } 
     return false;
}
问题回答

Page Owner is thecode>< entitled> tag and present at the Top of a browser database which is part of the

https://stackoverflow.com/questions/48079120/what-is-the-difference-between-chromedriver-and-webdriver-in-selenium/480871#48080871" 需要有focus,具体Browsing Context,以提取Page Owner/em>。

Window Handle是一个独特的识别标志,可保存所有窗户的地址,并能够回承印价值。 所有浏览器都将有一个独特的窗口。 <>getWindowHandles()功能有助于检索所有窗口的操作。

So Selenium driven WebDriver can collect the Window Handles from the Browsing Context even without having individual focus on them.


Conclusion

因此,可在而不是上查阅窗口/表格的名称,而不必转至具体Window / TAB





相关问题
C# List currently open files and programs

Is there a way I can get a list of all open applications and a list of all open files? For the files I only need the files that I opened (documents etc) not OS s open system files. The same for the ...

How to get the main window handle of a process using JScript?

Is there any method in JScript to get the handle of the main window of a process by providing the process name? The Process.MainWindowHandle property works only in JScript .NET. Is anything similar ...

Handling invalid window handle

The application retrieve window handles, using Enum* routines. It happens that in the while the application manage the handle (get class name, window statistics...) of an enumerated/created window, ...

Get all window handles for a process

Using Microsoft Spy++, I can see that the following windows that belong to a process: Process XYZ window handles, displayed in tree form just like Spy++ gives me: A B C D E F G H I ...

Get window handle from window class name

I m trying to get a window handle on a child window in my process and the only information I have is the window class name. Are there any win32 functions I can use for that? I m doing this from C#. ...

OutOfMemoryException, large Private Data

In previous series: OutOfMemoryException, stack size is huge, large number of threads I have a .net windows service that consumes a lot of memory. The GC heap is not big. Also the stack size is not ...