0

I am working on Desktop application using WinAppDriver and Selenium C#.

There are couple of links on the application.

If we click on the link, it will redirect to default browser.

How I can switch focus from WinAppDriver to IWebDriver ?

How to verify the link, whether the link opened in default browser or not?

Please help on this. Thank you.

Kiran
  • 1
  • 2
  • There is a way for you to capture the link on the application? Because it's easier to get the link and send the command to selenium to open the browser you need with that link. Otherwise, you'll have to attach the session already oppended by the redirect link with selenium, witch is not a easy task. – ojonasplima Dec 29 '21 at 16:50
  • @osfresia Thanks for your quick response. If possible can you please share the sample code? – Kiran Jan 04 '22 at 06:41
  • I can't post a exact code for that because I don't have samples about the windows, but you can try something like that: Use `Teststack.White` , `FlaUI` or any automation lib, capture the link and send the command to `Selenium` to open the page on the browser you want to, it's simple like that. – ojonasplima Jan 04 '22 at 12:42

1 Answers1

1
// Switch to new window opened
for(String winHandle : driver.getWindowHandles()){
    driver.switchTo().window(winHandle);
}

// Perform the actions on new window

// Close the new window, if that window no more required
driver.close();

// Switch back to original browser (first window)
driver.switchTo().window(winHandleBefore);
pawansinghncr
  • 181
  • 1
  • 7