checkly/headless-recorder

Pushing seclectors by attr(name=value) rather than div#ids

jtizol opened this issue · 4 comments

Hey guys, anyone know the level of effort to adjust the block building to select elements by attr "name" rather than id?

I am struggling with a page that dynamically assigns div IDs and it is unreliable to select by ID

from:

  await page.waitForSelector('div > .qx-widget > .qx-widget > #id_379 > div')
  await page.click('div > .qx-widget > .qx-widget > #id_379 > div')

to:

  await page.waitForSelector('div > .qx-widget > .qx-widget > [name="frmMain_pbSpecMaint"] > div')
  await page.click('div > .qx-widget > .qx-widget > [name="frmMain_pbSpecMaint"]  > div')

Hi @jtizol this is actually already implemented, just in a slightly different way. You can provide a custom data-* attribute in the settings. Puppeteer Recorder will then use that instead of the standard selectors. You would just need to instrument your code with this attribute of course.

image

@tnolet Are you saying that the div attr needs to be formatted with "data-name" attr? We've built the entire site using just the "name" attr. It would be really difficult to change everything at this point. Is there no way to just point the block builder to look at the "name" attr rather than "id"?

@jtizol that's what I'm saying, yes. the data-xxx is a very common pattern. Sorry, don't think there is another way right now.

@tnolet understood. Thank you for the feedback.