Adagio
7 years agoFrequent Contributor
Closing the current Tab in the Chrome browser
Hi,
I have a dashboard page open in the chrome browser. Here I search for an entity which opens up in a new tab, I veryfy some information on this and want to close this tab and go back to the dashboard page. I have to repeat this process at least 10 times for different entities.
I'ven't had any success in closing the tab consistently. Most of the time, this ends up closing the 'dashboard' page itself.
Here is what I'm using:
////////////////////Main////////////////////////////////////////////////// function main(){ /* Here goes the complete program to run the test */ // closing the current tab CloseTab(getURL()); } ///////////////////// Close the current tab in the browser ///////////////// function CloseTab(URL) { var browser = Sys.Browser("*"); var page = browser.Page("*"); Sys.Browser().Page(URL).Keys("^w") } /////////////////fetch the URL of current page in the browser/////////////// function getURL(){ var browser = Sys.Browser("Chrome"); var page = browser.Page("*"); var url = page.URL; return url; }
Any help would be appreciated!
Thank you
Abhi