Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING: New but browser orientated API #91

Merged
merged 24 commits into from
Dec 13, 2021
Merged

BREAKING: New but browser orientated API #91

merged 24 commits into from
Dec 13, 2021

Conversation

ebebbington
Copy link
Member

@ebebbington ebebbington commented Nov 4, 2021

  • New element class:
    const elem = new Element(...)
    elem.click()
     elem.value = "hello"
     elem.value // hello
  • Renamed goTo to location
  • Moved type into `Element#value
  • Move getInputValue to Element#value()
  • Move click() to Element#click()
  • Dont duplicate tests: single test file to run tests for every browser, as opposed to 2 tests files running the same code
  • Can use $x in evaluate: `client.evaluatePage('$x("//div")[0].innerHTML')

@ebebbington ebebbington marked this pull request as draft November 4, 2021 21:04
@crookse
Copy link
Member

crookse commented Nov 26, 2021

i think i left a message in the discord about this, but yes i agree

@ebebbington
Copy link
Member Author

might add page tbh, so something like

const { page } = await buildFor("chrome")
await page.cookie = "..."
page.cookie // ...
page.location = "..."
page.close() // pretty much just client.done()

@ebebbington
Copy link
Member Author

ebebbington commented Dec 11, 2021

Changes:

  • goTo on the Client now returns a Page class instance
  • setCookie has been moved to Page#cookie()
  • location() on the Page should be used to change the location of the page
  • evaluatePage has been moved to Page#evaluate
  • waitForPageChange has been moved to Page
  • takeScreenshot has been moved to Page
  • assertSee has been moved to Page
  • new querySelector method on Page which returns an Element
  • getInputValue and type have been moved to Element#value
  • click has been moved to Element
  • assertUrlIs has been removed, use assertEquals(await page.location(), "...") instead

@ebebbington
Copy link
Member Author

const Sinco = await buildFor(browserItem.name); // also supports firefox
      const page = await Sinco.goTo("https://drash.land"); // Go to this page

      // Do any actions and assertions, in any order
      assertEquals(await page.location(), "https://drash.land/");
      const elem = await page.querySelector(
        'a[href="https://discord.gg/RFsCSaHRWK"]',
      );
      await elem.click(); // This element will take the user to Sinco's documentation
      await page.waitForPageChange();
      const location = await page.location();

      // Once finished, close to clean up any processes
      await Sinco.done();
      assertEquals(location, "https://discord.com/invite/RFsCSaHRWK");

@ebebbington ebebbington changed the title new api? BREAKING: New but browser orientated API Dec 11, 2021
@ebebbington ebebbington marked this pull request as ready for review December 11, 2021 15:27
@ebebbington ebebbington requested review from drashbot, crookse and Guergeiro and removed request for drashbot December 11, 2021 15:28
@crookse crookse added the Type: Major Merging this pull request results in a major version increment label Dec 12, 2021
ebebbington and others added 8 commits December 12, 2021 20:26
Co-authored-by: Eric Crooks <crookse@users.noreply.github.com>
Co-authored-by: Eric Crooks <crookse@users.noreply.github.com>
Co-authored-by: Eric Crooks <crookse@users.noreply.github.com>
Co-authored-by: Eric Crooks <crookse@users.noreply.github.com>
Co-authored-by: Eric Crooks <crookse@users.noreply.github.com>
@crookse crookse self-requested a review December 12, 2021 22:43
Copy link
Member

@crookse crookse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. not sure if you plan to make anymore changes, but if you do, i'll just review the commits as the come in

@ebebbington ebebbington merged commit af26b82 into main Dec 13, 2021
@ebebbington ebebbington deleted the new-api-maybe branch December 13, 2021 19:43
This was referenced Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Major Merging this pull request results in a major version increment
Development

Successfully merging this pull request may close these issues.

2 participants