checkly / headless-recorder

Chrome extension that records your browser interactions and generates a Playwright or Puppeteer script.
https://checklyhq.com/headless-recorder
MIT License
15.03k stars 722 forks source link

SyntaxError: Octal literal in strict mode #66

Closed archcorsair closed 5 years ago

archcorsair commented 5 years ago

Puppeteer-recorder is grabbing this selector:

await page.waitForSelector('.error #\35 11\3A 0')

causing Puppeteer to throw this error: SyntaxError: /Users/nxc/w/salesforce-puppeteer/test/recorded.test.js: Octal literal in strict mode (73:39)

I suspect this might be a unique issue to the product I'm working with because it is a salesforce based application where it renders nested iFrames. Creating a test script manually works, using a helper I wrote to fetch the nested frame I need:

const getChildFrame = (parent, index) => {
  const wrapperFrame = parent.mainFrame().childFrames()[index]
  return wrapperFrame.childFrames()[0]
}

Any suggestions regarding this specific use case would be appreciated

archcorsair commented 5 years ago

Additional screenshot for context: image

archcorsair commented 5 years ago

Update: Doing some personal investigation lead me to these resources:

I've discovered the issue is that there is a limitation in CSS itself where if the id of the element starts with a number, it must be escaped. This is causing issues because the escape character itself \ is not being escaped when generating the script. I was able to fix the above error by additionally escaping the escape character.

Example: (was)

await page.click('.error #\35 11\3A 0')

Now:

await page.click('.error #\\35 11\\3A 0')
tnolet commented 5 years ago

Hey @archcorsair that is a nice corner case. Kudos on finding the solution. I don't think we are going to tackle this in Puppeteer Recorder. Closing this issue.