Closed auphofBSF closed 4 years ago
This PR Travis failures are addressed in PR #7
Thank you for writing this up and submitting it. It's definitely a novel solution that I had not thought of. I checked it out inside a Jupyter notebook to play around with it.
Pros:
dom.query_selector(...)
instead of session.execute(dom.query_selector(...))
or even (what I was imagining for this issue) session.dom.query_selector(...)
.target.get_targets()
work. I thought that command could only be called in the "root" session, but it works in all sessions. This simplifies away something that I expected to be a big problem.Cons:
simplify_cdp_domain_calls(domain)
on each domain, I would rather just call it once and get all of the domains decorated.This is a great PR for discussion, however. I have an idea I will post on the original issue.
I will close this PR , have not had time to merge #9 but cant see any issue, and look forward to trying it
The following PR is a candidate for Issue API redesign Issue: #1 It allows an alternative call directly to the domain function ie `page.navigate('https://example.com')
see the
examples/get_title_simple_calls.py
This PR is offered as a discussion, there are many ways to do this, so I thought I will just try 1 way and see what roadblocks emerge. The session is stored in a Singleton class. The cdp api is decorated with the necessary calls and is then transparent in that the documentation is passed through as well, results etc,
One can change the session by
CDP_Active_Session_Manager.getInstance().session = await conn.open_session(<TARGET_ID>)
Possibly something can be done to here to enable switching different sessions by some form of context - Needs further explorationThis has been a steep learning exercise in decorators and I do not profess to have a perfect implementation but it is working for me and my source code is tidy.
I have been using this in Jupyter with great work done by @mehaase in gettting trio to work in Jupyter using the GLOBAL_NURSERY.
For working in jupyter ensure IPython 7.12 is installed and install the ipykernal from https://github.com/HyperionGray/ipykernel.git checkout branch trio-loop and install for development with
pip install -e .