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

allow setting panic func for browsers #433

Merged
merged 3 commits into from
Jun 5, 2021
Merged

Conversation

egonelbre
Copy link
Contributor

This adds customizable panic to Browsers.

Note, I'm not sure whether adding it to RaceContext, Mouse, Keyboard and Touch is necessary. But, I can remove them and call their associated page methods.

For Pages, I needed to use the first pages .e rather than inherit it from the parents. Adding a .e to that type, would make a backwards incompatible change to Pages type and make using it more annoying. So, I decided to go the easier route and fallback to utils.E when there isn't a suitable page.

Based on #428.
Fixes #424.

@ysmood ysmood mentioned this pull request Jun 1, 2021
3 tasks
@egonelbre
Copy link
Contributor Author

Btw. is there a nice way to retrigger the github actions without having to update the PR.

I'm not sure whether this is testsuite.

@ysmood
Copy link
Member

ysmood commented Jun 1, 2021

Btw. is there a nice way to retrigger the github actions without having to update the PR.

Do you mean this?

image

@egonelbre
Copy link
Contributor Author

@ysmood I don't have sufficient permissions for it.

@egonelbre
Copy link
Contributor Author

I ended up repushing.

@ysmood
Copy link
Member

ysmood commented Jun 1, 2021

I ended up repushing.

I spend some time checking permission settings, seems like they don't have one for it.

@egonelbre
Copy link
Contributor Author

Ah, also, this should be ready for review.

@ysmood
Copy link
Member

ysmood commented Jun 2, 2021

Great! Give some time to review.

Copy link
Member

@ysmood ysmood left a comment

Choose a reason for hiding this comment

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

Note, I'm not sure whether adding it to RaceContext, Mouse, Keyboard and Touch is necessary. But, I can remove them and call their associated page methods.

I think it's better to keep the same design as Context, for example, if a user wants to use a custom panic they can do this:

browser.WithPanic(Panic).Hijack()

The hijack can just use the e from its internal browser object.

No need to do this:

browser.Hijack().WithPanic(Panic)

@egonelbre
Copy link
Contributor Author

@ysmood it's still taking the e from the browser.e. 965825e. There's no separate WithPanic.

Just to clarify whether I understand you correctly. It would be fine to call r.browser.e( in the methods. And the same goes for RaceContext, Mouse, Keyboard and Touch?

@ysmood
Copy link
Member

ysmood commented Jun 4, 2021

Just to clarify whether I understand you correctly. It would be fine to call r.browser.e( in the methods. And the same goes for RaceContext, Mouse, Keyboard and Touch?

Yes, the design style is that use as few private states as possible.

@egonelbre
Copy link
Contributor Author

Hopefully, this is more aligned with what you had in mind.

Copy link
Member

@ysmood ysmood left a comment

Choose a reason for hiding this comment

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

Good job, almost there!

I think you forget to add the WithPanic methods for Page and Element in the must.go file?

ysmood and others added 3 commits June 5, 2021 16:34
This makes following use panic helper:
* Mouse, Keyboard, Touch
* RaceContext
* HijackRouter, Hijack
@ysmood ysmood merged commit 92f15d6 into go-rod:master Jun 5, 2021
@egonelbre egonelbre deleted the custom-panic branch September 22, 2021 10:53
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.

Easier way to avoid panic with Must helpers.
2 participants