Closed ebebbington closed 2 years ago
I dont want to make another major version, but the internal code and API needed to change
and a bunch of QOL stuff for us:
client.close()
, for which the error shoudl be thrown withwe mixing and matching camel case and snake case object keys 😬 . honestly, i don't know if we should continue to be uniform with these. reason being in the Open API service i'm working on in Drash, Open API Specification uses camel case for object keys, so the Open API service needs to build Open API Specification objects using camel case. kinda sucks, but it killed our uniformity. i know a solution would be to use snake case and then convert all snake case keys to camel case, but that seems unnecessary.
want your thoughts though on if we should continue to enforce snake case in our codebase OR do it based on requirements. like since Open API Specification requires camel case, then the Open API service should use camel case.
lets just do snake case all the way
Why? Sinco only really supported one page, and sometimes it made no sense.. Say you click a link and it opens a new tab, you still only have one 'page' and there's no way to get back to your original page. Some methods (such as click()) were using a hacky approach to get a solution. A lot of properties and methods on classes (internal methods) didnt make sense for them being on those classes
What?
renamed Client#done to Client#close:
await browser.close()
>await browser.done()
Moved a lot from the protocol class to be under the client, as it didnt belong, such as browser process, browser, firefox path
The client's connection was actually the page's, which makes no sense, so i've made the client class use a separate connection which isn't connected to a page, but can be used for general browser things
Client#create now returns
{ browser, page }
, it's more semantic for it to be named "browser" instead of client or Sinco, and we know they want to make a page, so we make sure to do that for them here. Whilst a page did open originally, the change here is we create a page instance and attach to it:Support for multiple pages. Whilst you can't directly create a page yourself, if a new tab/page is openedin the browser, a new item gets pushed to
Client#pages
, which can control that page:If any action will open a new page,
button: "middle"
needs to be passed toclick
for us to properly handle these different pagesCan now close a single page
Can focus a page (but doesnt really do anything)
Removed waitForPageChange(), instead use .click({}, true)
Removed selector from takeScreenshot, instead moved this to Element class, so to take a screenshot of an element, you'd call it on the element instead of a page
The tree is: