Telerik blogs

Occasionally a customer will want to do something unusual like close a tab in Chrome. I worked on this request today and I found some interesting things. I though it might be nice to share my finding. First off:

  • Test Studio doesn't like tabs - you should always open links in a new window

Some browser actually allow you to pick your preference - open links in tabs or new windows. If the option is available - you should always go by "new window" (but Chrome does not have it). A new window is actually a pop up and Test Studio can handle these flawlessly as seen here.  But I discovered something interesting when it comes to clicks in Chorme. If you use SimulateRealClick=true - it will cause cause the link to open in a new tab. On the other hand if you set it to SimulateRealClick=false it will open the link in a new window. If you don't know about SimulateRealClick check out my blog post on that.

So if you're using Chrome you can:

  • Open a new tab by setting the click to SimulateRealClick=true

Going back to the original problem: how can you close the tab once it's been opened. You will NOT be able to use the following coded step:


because that would close the entire browser along with all its tabs.


Instead you can use the Chrome keyboard shortcut and:

  • Simulate a CTRL+W keypress on the tab in order to close it

The way you do that is through a coded step that will look like this:


This approach worked for me. But again I must stress that we recommend that you avoid using tabs in any shape or form while performing test automation with Test Studio. I hope you will find this info of interest.

About the author

Stoil Stoichev

Stoil Stoychev

has been helping customers solve their complex testing challenges leveraging his in-depth knowledge of Telerik Test Studio. He has traveled the globe fine-tuning his technical expertise and helping our valued clients succeed. In his spare time he enjoys motorcycles, live music and various sports.


Comments are disabled in preview mode.