Skip to content

Conversation

kylefmohr
Copy link

@kylefmohr kylefmohr commented Jun 24, 2025

Description

Specifically, this fixes tests/bot_detection/test_browserscan.py by changing the traversal order: Instead of checking the current node for a match before its children (pre-order traversal), we check the children first (post-order traversal). This ensures that if a match exists deeper in the DOM tree, it will be found before any of its ancestors.

The other change that this makes is that it ignores matches of text nodes directly, instead letting the parent elements be the match. This is because we are interested in the element containing the text, not the text node itself.

Finally, I started work on fixing tests/core/test_tab.py::test_find_finds_element_by_text but haven't completed it yet. Specifically, I changed the ordering of parameters in functions that have the two new parameters. I moved text to be the first parameter, as test_tab.py makes that assumption here:

result = await tab.find("Apples")

and I think that is a fair assumption to make.

Pre-merge Checklist

  • I have described my change in the section above.

  • I have ran the ./scripts/format.sh and

  • ./scripts/lint.sh scripts. My code is properly formatted and has no linting errors.

  • I have added my change to CHANGELOG.md under the [Unreleased] section.

raycardillo and others added 30 commits February 11, 2025 19:44
* 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

* add expect_download

* format

* fix conflict

* Update CHANGELOG.md

* Update zendriver/core/expect.py

Co-authored-by: Stephan Lensky <[email protected]>

* add test_expect_download

* Update test_tab.py

---------

Co-authored-by: Stephan Lensky <[email protected]>
stephanlensky and others added 19 commits April 27, 2025 22:56
* Update CDP models

* Removed cdp.browser.PermissionType.FLASH from the removed permissions when granting *all* permissions since it was removed from CDP

* Added changelog entry

---------

Co-authored-by: Stephan Lensky <[email protected]>
* fix: allows tests to be run on windows (SIGUSR1 not supported)

* fix: escape url pattern for regex, since windows uses backslash which makes it crash

* fix: using forward slashes in file path since cdp always returns back forward slashes

* run format + update changelogs

* feat: run ci on windows

* portable way to get chrome version (windows fix)
* fix: adding a missing chrome canary path

* fix: adding a missing chrome canary path (changelogs)

* fix: re-enabled --load-extension flag (disabled by default in Chrome 136+)
…lectorEventLoopPolicy` on Windows (cdpdriver#117)

* feat: adding disable_asyncio_subprocess to use subprocess.Popen instead (for better support on Windows)

* test and document with WindowsSelectorEventLoopPolicy

* update changelogs

* disable_asyncio_subprocess defaults to True on Windows

* using subprocess.Popen for all platforms

* apply format
…#128)

* alternate method that supports special chars (e.g. emojis)

* changelogs

* replacing send_keys_with_special_chars with special_characters parameter in send_keys

* Update CHANGELOG.md

---------

Co-authored-by: Stephan Lensky <[email protected]>
…_up (cdpdriver#132)

* feat: being able to choose scroll speed in Tab scroll_down and scroll_up

* changelogs

* fix: waiting for scroll + set speed in example to avoid loading multiple times

---------

Co-authored-by: Stephan Lensky <[email protected]>
…er#135)

* feat: add option to wait for promise in Element.apply method

* Update element.py

Co-authored-by: Stephan Lensky <[email protected]>

* reorder doc

---------

Co-authored-by: Stephan Lensky <[email protected]>
@kylefmohr
Copy link
Author

The reason I ran into ./scripts/lint.sh errors has to do with the fact that PR #55 removes the best_match parameter, and network_monitor.py would need to be updated to reflect that. I just wanted to check on your thoughts about removing best_match or keeping it.

…example to explicitly define `best_match`, readded `expect.py` which was missing from this branch.
@kylefmohr kylefmohr marked this pull request as ready for review June 24, 2025 19:39
@kylefmohr
Copy link
Author

I've re-added the best_match implementation. This now passes all tests and should be ready for review.

@nathanfallet
Copy link
Member

nathanfallet commented Jun 25, 2025

Hello, thank you for the PR!

Could you merge or rebase your branch on the current main one? It would make the review way easier, since files were moved (e.g. the expect.py file, which is newer than your base commit, or the various methods that were moved inside tab.py); so real changes would directly appear.

@kylefmohr kylefmohr marked this pull request as draft June 25, 2025 19:43
Copy link
Contributor

github-actions bot commented Aug 1, 2025

This pull request was automatically closed because it has been inactive for 7 days since being marked as stale.

@github-actions github-actions bot closed this Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants