-
Notifications
You must be signed in to change notification settings - Fork 765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functionality provided by new Selenium 4 create and/or switch to new window or tab #1823
Comments
Some of my initial notes on Create and Switch to a new (blank) tab or window
[Ed M.: I have very little usage of the create windows or switching windows in my past history of using the library. So this is an area that I don't have much ideas for or deep understanding on usage, needs and best practices] |
@emanlove This functionality is currently used in my automation and in many places so I was currently doing the same thing that is suggested in your comment that we have to switch it using window handles but that keyword creates flaky testcases and I would like to work on this open issue |
@Antimatterr are you saying the window handles keyword GetWindowHandle causes test flakiness, am I reading that correctly? I'd like to know more about that. Are the tests flaky because of how they're using the GetWindowHandle, or how they are switching, or... I can't help you with the coding but would be happy to discuss the options for behavior. It seems to me more ideal to open the new window, switch automatically, and then close it when done, but I am not surprised that some apps require more complex window switching than that. |
@lisacrispin Regarding the GetWindowHandle function, I've observed that it exhibits varying behavior across different browsers, particularly in Safari. When multiple windows are open, each assigned with a distinct identifier such as '222' and '333', the function returns an array of IDs in reverse order. Specifically, the older window ID occupies the 0th index, while the newer one is placed at the 1st index, resulting in the sequence [333, 222]. However, in Chrome, the order is completely opposite, with the older ID at the 0th index and the newer ID at the 1st index, forming the pattern [222, 333]. This inconsistency deviates from the standard behavior and has necessitated debugging efforts. While alternative approaches, such as utilizing multiple keywords to switch between tabs, have been suggested, this method of elimination does not align with the expected functionality. In scenarios where two tabs are opened, and one takes longer to load than the other, it becomes challenging to determine which window handle corresponds to each tab. Consequently, this lack of clarity renders our tests unreliable. Hence, it is imperative to incorporate an automatic switching or tab creation functionality to mitigate these issues. |
As noted in the SeleniumLibrary docs it is already now possible to open a new Window and switching to it. https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Browser%20and%20Window
i agree that this can be improved. proposal Also the docs of Switch Window describe that the locator I would also say that it should be possible to very reliable switch to the newest Tab by first getting all Handles and then opening the new Tab and then Switching to the newest one by using the list of handles as exclusion list. |
After some thoughts i would not go with some other thoughts to this topic: it is already possible to switch to windows by their title ( the window.name could optionally set be by that keyword. Even though i do not think that Tab vs Window is important, that could also be an argument to |
As per the Selenium documentation [1], "Selenium 4 provides a new api NewWindow which creates a new tab (or) new window and automatically switches to it.". This is compared to the previous behavior where "[c]licking a link which opens in a new window [would] focus the new window or tab on screen, but WebDriver will not know which window the Operating System considers active. To work with the new window you will need to switch to it. If you have only two tabs or windows open, and you know which window you start with, by the process of elimination you can loop over both windows or tabs that WebDriver can see, and switch to the one which is not the original."
References:
The text was updated successfully, but these errors were encountered: