0

My problem is when I click on a desktop icon, it opens a link in already opened chrome browser in a new tab. How do I attach with the already opened browser and not a new one?

The below code returns a null because there is no window opened through selenium ofcourse, so yeah.

Set<String> windows = webdriver.getWindowHandles();
System.out.println(windows);

Any suggestions would be of great help. Thanks In advance.

1 Answers1

0

There is no way to attach the chrome window that you've opened from the desktop application to your WebDriver instance.

If you want to be able to control a web page with a Selenium - you must pass your URL to a driver like that:

 webdriver.get("https://www.your_link.com");

You might think about the way of getting and storing your URL as a variable and passing it into your code.

That would also be helpful if you add a bit more details about the problem. It's a bit unclear at what stage of the test you open the web page with a desktop application. Selenium can't be used to test desktop applications. Code sample of the test from your project would also help.

doomguy
  • 1
  • 1