grg-n-sox
grg-n-sox

Reputation: 717

How do I capture a browser launch link request in a selenium test?

I have some selenium tests that run for an application with some embedded webviews. The problem is that one of the links inside this embedded webview explicitly opens the linked site in an external browser. This is a problem because I can't attach the webdrivers that selenium uses to the new browser instance to continue the test because it wasn't opened by the webdriver.

See: https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/18

I tried preemptively opening a browser window, then clicking the link hoping it would open as a new tab inside the already opened browser. No dice. It still opened a new browser instance.

Ideally I could intercept the link call on the click event, grab the url, and launch it myself through the webdriver and figure it would be close enough to the real event. This would also get around the issue of not knowing what the default browser is for the environment the tests are run in. How would I go about doing this?

Upvotes: 0

Views: 100

Answers (1)

crookedleaf
crookedleaf

Reputation: 2198

Have you checked to see if it is just opening a new window_handle? If so, you could easily switch to that window handler. I don't know what programming language you are using, but you can check out the documentation here to see examples for whichever language you are using.

Upvotes: 0

Related Questions