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

add remove_handler, wait_for_load_page, expect_response, expect_response #40

Merged
merged 15 commits into from
Feb 6, 2025

Conversation

3mora2
Copy link
Contributor

@3mora2 3mora2 commented Jan 26, 2025

  • add remove_handler to stop listen to event
  • add expect_response, expect_response as in playwright-python
  • add wait_for_load_page to wait until page loaded

- add remove_handler to stop listen to event
- add expect_response, expect_response as in playwright-python
- add wait_for_page_load to wait until page loaded
Copy link
Owner

@stephanlensky stephanlensky left a comment

Choose a reason for hiding this comment

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

Thanks for the submission! I left a few comments, let me know when you have a chance to look at them.

Overall, the RequestExpectation/ResponseExpectation is a neat idea, if we can clean it up a bit I'd be happy to accept it into the library.

One additional note: can you please autoformat and lint the code using the scripts/format.sh and scripts/lint.sh scripts? Thank you.

zendriver/core/tab.py Outdated Show resolved Hide resolved
zendriver/core/tab.py Outdated Show resolved Hide resolved
zendriver/core/tab.py Outdated Show resolved Hide resolved
examples/wait_for_page.py Outdated Show resolved Hide resolved
zendriver/core/tab.py Outdated Show resolved Hide resolved
zendriver/core/tab.py Outdated Show resolved Hide resolved
zendriver/core/connection.py Outdated Show resolved Hide resolved
examples/wait_for_page.py Outdated Show resolved Hide resolved
3mora2 and others added 2 commits January 29, 2025 00:25
- fix `remove_handler`
- improve `expect_*`
- improve `RequestExpectation`
@3mora2 3mora2 requested a review from stephanlensky January 29, 2025 00:34
Copy link
Owner

@stephanlensky stephanlensky left a comment

Choose a reason for hiding this comment

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

Thanks, I left a few more comments.

Did you see my note here?

can you please autoformat and lint the code using the scripts/format.sh and scripts/lint.sh scripts? Thank you.

examples/wait_for_page.py Outdated Show resolved Hide resolved
zendriver/core/tab.py Outdated Show resolved Hide resolved
zendriver/core/connection.py Outdated Show resolved Hide resolved
zendriver/core/tab.py Outdated Show resolved Hide resolved
zendriver/core/tab.py Outdated Show resolved Hide resolved
zendriver/core/tab.py Outdated Show resolved Hide resolved
zendriver/core/tab.py Outdated Show resolved Hide resolved
zendriver/core/tab.py Outdated Show resolved Hide resolved
zendriver/core/tab.py Outdated Show resolved Hide resolved
zendriver/core/tab.py Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
@3mora2 3mora2 requested a review from stephanlensky February 3, 2025 03:04
@khamaileon
Copy link
Contributor

Hey guys, I'm following this pull request closely because it addresses two issues I've already encountered. However, I think it could use a bit more documentation and, most importantly, some unit tests. What do you think? Let me know if I can help as well.

@stephanlensky
Copy link
Owner

Agreed, happy to take some help here, I won't have time to do either of those things anytime soon. I'll leave it to you to coordinate though.

BTW, sorry for the delay in the final review, I'll try to get to it tonight.

@khamaileon
Copy link
Contributor

Hi @3mora2, I moved remove_handler to a separate pull request. I made some changes and added a few tests. Feel free to take a look and share your feedback!

@stephanlensky
Copy link
Owner

Hey @3mora2, as @khamaileon mentioned, I just merged another PR to add remove_handler here: #50

You'll want to merge latest master to get the change.

Otherwise, after we switch to using regular expressions and get the change added to CHANGELOG.md I'll be happy to merge this and release a new version for you.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @3mora2 Thank you for spotting this. I believe this should never have gone this far, and it's better to alert the user of their mistake. Here’s a suggestion: #52

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @khamaileon, Ok

@stephanlensky
Copy link
Owner

stephanlensky commented Feb 6, 2025

I just merged #52 and fixed the conflict in this PR. Almost ready to merge, but looks like there is a lint issue with the expectation classes (see here).

Maybe we can fix this by having both of them derive from an abstract base class?

I'll try to take a look at fixing it tonight if you don't get to it first.

BTW, do you want credit for the change? You can add it in the CHANGELOG.md.

If you want, you can also update the line in CHANELOG.md for tab.remove_handlers to add your name since you worked on it together with @khamaileon.

@3mora2
Copy link
Contributor Author

3mora2 commented Feb 6, 2025

check it

@stephanlensky stephanlensky merged commit eedfded into stephanlensky:main Feb 6, 2025
@khamaileon
Copy link
Contributor

khamaileon commented Feb 6, 2025

@stephanlensky be careful, in CHANGELOG you talked about wait_for_page_load instead of wait_for_ready_state.

Sorry, I misread; it was the commit change message.

stephanlensky added a commit that referenced this pull request Feb 7, 2025
…nse (#40)

* add remove_handler, wait_for_load_page,

- add remove_handler to stop listen to event
- add expect_response, expect_response as in playwright-python
- add wait_for_page_load to wait until page loaded

* improve

- fix `remove_handler`
- improve `expect_*`
- improve `RequestExpectation`

* improve and format

* Update .gitignore

* change to re.fullmatch

* Update connection.py

* Update tab.py

* Update CHANGELOG.md

* Update CHANGELOG.md

---------

Co-authored-by: Stephan Lensky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants