const browser = require('../browser');

module.exports = async ({ selector }) => {
  if (!selector) {
    throw new Error('Selector é obrigatório');
  }

  await browser.start();
  const p = await browser.ensurePage();

  await p.waitForSelector(selector, { state: 'visible', timeout: 10000 });
  await p.click(selector);

  return {
    success: true,
    action: "click",
    selector
  };
};
