You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey lucgagan, I really love this project.
I noticed that the API requires you to pass in the same options every time you call auto. Would you consider a more object-oriented approach like this one so users can initialize the function once and then call it repeatedly with the same state? This would also be useful for setting token limits and other configurations due to the nature of the persistent state in objects.
Here's the kind of syntax I was imagining:
importAutoPlaywrightfrom"auto-playwright";constap=newAutoPlaywright({openAiKey: "sk-...",model: "gpt-4-1106-preview",// this can mirror the model types from OpenAI// ...whatever else here});ap.auto("Get the text of the first link",{ page, test })
Let me know what you think, as this would be a bigger change, so I didn't want to start coding anything yet, but I think taking up this approach would have numerous benefits like the ones I mentioned previously. This is also similar to how many other packages behave.
Thanks!
Keep up the good work man
The text was updated successfully, but these errors were encountered:
consttest=base.extend<{auto: TodoPage}>({auto: async({ page, test },use)=>{awaituse((instructions,options)=>{returnauto(instructions,{ page, test },options);});},});
Now you could just use it like:
test("auto Playwright example",async({ auto, page })=>{awaitpage.goto("/");constheaderText=awaitauto("get the header text");awaitauto(`Type "${headerText}" in the search box`);constsearchInputHasHeaderText=awaitauto(`Is the contents of the search box equal to "${headerText}"?`);expect(searchInputHasHeaderText).toBe(true);});
Hey lucgagan, I really love this project.
I noticed that the API requires you to pass in the same options every time you call
auto
. Would you consider a more object-oriented approach like this one so users can initialize the function once and then call it repeatedly with the same state? This would also be useful for setting token limits and other configurations due to the nature of the persistent state in objects.Here's the kind of syntax I was imagining:
Let me know what you think, as this would be a bigger change, so I didn't want to start coding anything yet, but I think taking up this approach would have numerous benefits like the ones I mentioned previously. This is also similar to how many other packages behave.
Thanks!
Keep up the good work man
The text was updated successfully, but these errors were encountered: