// this clicks on the link after page is loaded,
// there is whole process going before coming to this point.
await page.click('#ctl00_chpMain_ucContractDetails');
const url = await newPage.evaluate(() => document.location.href);
console.log(url); // this code didnt work for me.
You need to catch the tab creation event:
const [url] = await Promise.all([
new Promise((resolve, reject) => {
browser.once('targetcreated', (target) => { resolve(target.url()); });
}),
page.click('#ctl00_chpMain_ucContractDetails'),
]);
console.log(url);