async function clickDownloadLink(browser, url, text) {
  const page = await browser.newPage();
  await page.goto(url, {waitUntil: 'networkidle2'});

  const downloadUrl = await page.evaluate((text) => {
    const link = document.evaluate(`//a[text()="${text}"]`, document,
        null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
    if (link) {
      link.click();
      return link.href;
    }
    return null;
  }, text);

  await page.close();

  return downloadUrl;
}
@param {!Browser} browser
@param {string} url The url of the page to navigate to.
@param {string} text The link with this text to find and click on the page.
@returns {!Promise<?string>} The download resource's url.