closing browser within chrome page on test complete

532 views Asked by At

So using TestComplete I'm essentially trying to open up a session on chrome, navigate to a web page, and then click a button on that page. after I'm finished I want to close that browser page. I'm having trouble closing the page though. Here is the code I have so far.

function ChromeTest
{
    Browsers.Item(btChrome).Run(MyWebAdress);
    var browser = Sys.Browser("chrome");
    var page = Sys.Browser("chrome").Page(MyWebAdress);

    var MyButton = page.ButtonLocation;
    MyButton.click();

    browser.BrowserWindow.Close(5000);
}

however, at the Close line I get an error that says "Unable to find the object BrowserWindow". Thanks in advance for any help you have.

1

There are 1 answers

0
Helen On BEST ANSWER

Change BrowserWindow to BrowserWindow(0) (or whatever index you see in the Object Browser):

browser.BrowserWindow(0).Close(5000);

Or you can call Close() directly on the Chrome process:

browser.Close(5000);