I am having problem understanding the syntax of how to switch between windows. The standard syntax is:
Set <String> stringHandles = driver.getWindowHandles();
for (String handle:stringHandles)
However, I think that it will only work, if the first element in the Set is a the primary window. If so,in for loop it will first switch to itself and only then to the secondary window. Am I right so far? Also, I see that if the first element in the Set is the secondary window, then it will switch to secondary and then it will go back to the primary window.Thus, the syntax above is imperfect and to make sure that we switch to the secondary window, we need to store the value of the primary window and then insert a condition that the handle of the window than we want is not equal to the value of the original window. Am I right in my reasoning?