@CodeWriter I think you might be misunderstanding which tab is being called "Active" in the UDF. The active tab isn't the one that is currently visible, but rather, the one that is being used currently by the WebDriver If you want to check which tab the user is currently using, then one option is to execute some javascript on each tab until you find the active one... the JavaScript is as simple as document.visibilityState Here's a function that will get the handle of the window