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

Features and Changes #28

Closed brandon-bethke-timu closed 6 years ago

brandon-bethke-timu commented 6 years ago

Hopefully these changes are not considered offensive. The new features should be considered beta and may be modified in the future.

[
   {
      "name":"accessToken",
      "value":"",
      "domain":".fake.com",
      "path":"/"
   },
   {
      "name":"namespace",
      "value":"alpha",
      "domain":".fake.com",
      "path":"/"
   }
]
{
    "localstorageoption1": "1",
    "localstorageoption2": "0"
}

Sanitized sample script using new code generation.

const puppeteer = require('puppeteer');
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.setCookie({"name":"accessToken","value":"","domain":".fake.com","path":"/"})
await page.setCookie({"name":"namespace","value":"alpha","domain":".fake.com","path":"/"})

await page.setViewport({ width: 1932, height: 604 })

await page.goto('https://www.fake.com')

await page.evaluate(() => {
  localStorage.setItem("localstorageoption1", "1")
  localStorage.setItem("localstorageoption2", "0")
})

var item = await page.waitForXPath('//EXPANDED-SIDE-BAR-HEADER-ITEM-TEXT[normalize-space() = "Mailboxes"]', {visible: true})

var item = await page.waitForSelector('nav-side-bar-option:nth-child(3)', {visible: true})
await item.asElement().click('nav-side-bar-option:nth-child(3)')

var item = await page.waitForSelector('.search-box', {visible: true})
await item.asElement().type('Smoke')

await page.keyboard.press('Enter');

var item = await page.waitForXPath('//SEARCH-RESULT-TITLE[normalize-space() = "Smoke Test"]', {visible: true})
await item.asElement().click()

page.waitFor(2000)
await browser.close()
tnolet commented 6 years ago

@brandon-bethke-neudesic thanks for working on Puppeteer Recorder. I went through your PR and I love some of the ideas! However, I cannot merge this PR. There are too many different features, updates etc. going on in one PR. Also, some of the changes are beta or very specific to your use case that are probably better left to individual users to add themselves to the code once generated, i.e. the waitForX selectors with timeouts, the custom elements.

This was not very clear for contributors, my bad, so I just added a CONTRIBUTING.md file to the master branch which lays out some rules regarding contributing PR's.

Having said that, the following features fit with the overall project and should appeal to more users:

Would love to chat about this and discuss implementation in a related issue.