Child window is closing automatically after parent window is launched in single sign-on (SSO) website using Edge - selenium

Steps
Navigate to single sign-on webpage using Edge driver.
After passing url in main webpage after SSO login, child window will open.
On child window, a select button is clicked
When the script is run, it is not navigating to next screen after child window is clicked. Edge driver is closing child window automatically.
I am using 109.0.1518.78 version of Edge driver.
There is no issue with the code because I launched the website and clicked on child window is closing automatically.
Is there an issue with Edge driver? I tried using Selenium v4+.
Any idea why it's not navigating to the next screen after click in child window?

Related

getWindowHandles not working properly with latest edge browser version

I am working on an application which supports only Edge Browser.
The login functionality works as follows -
On the login screen, when username and password values are provided and login button is clicked, a new browser window opens with an active alert pop-up saying Login Successful along with OK button similar to the image below -
Also, when this new window opens, the old browser window goes blank.
When user clicks on this OK button (or hits ENTER button on keyboard), user home page loads on this new browser window itself and the old window remains black throughout the session.
Automation -
To handle this flow in automation, I have used getWindowHandles() method where I get the handle of this newly opened window and accept the alert.
This used to work properly till edge browser version 105.
However, when the edge browser version was upgraded to 107, I started facing the issue where the getWindowHandles() method goes into infinite loop and eventually the test times out.
I also tried to simulate ENTER button hit by using Robot class but it made no difference.
I have tried using the edge-driver version matching with the current browser version 107 but the issue persists.
Can someone please let me know what can be done for this? Is these any known issue with newer edge browser version?
Thanks in advance..!!
This is the code written to handle multiple windows and the test times out at getWindowHandles() method itself.
for(String wh : driver.getWindowHandles()){
driver.switchTo().window(wh);
}
Adding a Wait may be the key to this problem:
WebDriverWait wait = new WebDriverWait(driver,20);
BTW, I've tested in Edge 108 (also with Edge Driver 108). There's no such error message and everything works great. You can upgrade to 108 and see whether this issue has been fixed.

How to save a PDF opened in IE new browser

I have a scenario to save a PDF which is opened in a window. By default selenium control moves to the Window, As it is a banking application I cannot repost the URL to save the pdf, I cannot press CTRL + S and right click doesn’t have any required data but using Robot I can click or move to an element, now the save button will enable only if you mouse over at the bottom of the page. I tried using ROBOT mouse over but the pop up did not popped up may be the reason it is not navigating via UI.
I have tried Sikuli also as the save pop up only pop up while mouse over that also failed.
We cannot use Actions as it wont support Webdriver driver, I have used Sikuli and ROBOT class mouse over.
The save Pop up opens only when it is mouse over at the bottom of the page, and it is not happening in ROBOT class as it navigates via DOM. please help

Windows vs tabs in Selenium

As per Difference between webdriver.Dispose(), .Close() and .Quit()
driver.close closes the current active window where driver.quit closes all of the windows. What I get is if I opened a new tab in my current window and then called driver.close the whole windows including my tabs would close. But when I run that code
driver.get("http://testingpool.com/selenium-ide-part-1/");
driver.findElement(By.xpath("//*[#id='content']/div[2]/article/div/div[2]/div[1]/p[8]/span/a")).click(); //opens a new tab
ArrayList<String> allWindowHandles = new ArrayList<> (driver.getWindowHandles());
driver.close()
only the first tabs gets closed. Also I find that my allWindowHandles has length of 2 although I have only one window.
I was trying to open a new window using Selenium as per https://www.tutorialspoint.com/how-to-open-a-new-window-on-a-browser-using-selenium-webdriver-for-python using
((JavascriptExecutor)driver).executeScript("window.open('')");
but that resulted in a new tab not a new window.
I am confused if Selenium differentiates between a tab and a window at all or not.
With the terminology used to distinguish between driver.close() and driver.quit() methods supported by Selenium WebDriver in the post you are referencing to, they actually mostly mean browser tabs, not windows.
By opening a new browser window with
((JavascriptExecutor)driver).executeScript("window.open('')");
or by clicking on some web element opening a new browser tab/window is will normally open a new tab in the existing browser.
What I get is if I opened a new tab in my current window and then
called driver.close the whole window including my tabs would close.
But when I run that code
See you may have opened a new tab by clicking on link or using JavascriptExecutor but Selenium still has focus on first tab of the first window.
Therefore, when you do this:
ArrayList<String> allWindowHandles = new ArrayList<> (driver.getWindowHandles());
driver.close()
It should close the first tab or window, since you have not switched to new tab/window.
Also I find that my allWindowHandles has length of 2
this is cause you have opened a new tab using this line
driver.findElement(By.xpath("//*[#id='content']/div[2]/article/div/div[2]/div[1]/p[8]/span/a")).click(); //opens a new tab
the moment you open a new tab by clicking on a link or Using JavascriptExecutor, you will have +1 windows handle.
However, if you do not switch to any tab or window/s. Selenium will always have focus on first tab of the first window.
Also, window.open('') is Js command not Selenium.
there is a difference between a new tab or windows. But if you take Selenium into consideration, We switch to new tab or windows in a same way.
However to open a new window, you would have to simulate CTRL+N keyboard action.

Capturing a newly opened window with Selenium

I'm using the Selenium Client drivers to run tests built in C#. I'm having a problem where the test navigates to a page and clicks on a button in a form with its target set to _blank causing it to open a new window. However the new page being opened returns an XML document and not a typical webpage. Selenium seems to have trouble with this because it hangs when the button is click and the new window opens. No instructions after the click method are executed. The test eventually fails with the error Timed out running command.
Any help/guidance would be appreciated. I've scoured the net but haven't seen anyone running into this particular issue of the page being opened not being a typical webpage which I think is the core of the problem as Selenium can't really manipulate this new opened window. I would post code except that literally all I'm doing is calling the click method on a button which causes a new window to open. Thanks in advance.
To tackle the issue of opening in new window. I typically get url of the link which is to be opened and instead of using selenium.click(), I use:
selenium.open("http://yourwebsite/yourlink")
This helps me to be on the same window only(which avoids opening new window or tab) and when the testing is finished on this page and you want to switch back to original page you can again use:
selenium.open("http://whatever/")

Uploadify - file select dialog goes behind the popup window

I am using uploadify in a child window. that is if i click on a image it will open a new window using javascript.. inside the child popup window, i am having the uploadify.
everything works fine. but when clicking Browser Files flash button, the file select dialog goes behind the child window. anybody please help to focus the file select dialog to the current popup window.
Do you have a link so we can test this? It seems like a problem on how your computer is rendering dialogs.
I believe the browser can't control whether the dialog will be created on top of all windows or behind all windows.