fate0 / pychrome

A Python Package for the Google Chrome Dev Protocol [threading base]
Other
612 stars 112 forks source link

Add chrome instance capabilities #25

Closed iiLaurens closed 6 years ago

iiLaurens commented 6 years ago

I propose a new version in which PyChrome automatically initiates a chrome service if no url was given to the Browser class. This takes the effort away from the end user to manually start or write code to start Chrome.

By default, a headless chrome instance will be started. At every start, a new chrome user is created in order to start with a clean slate and make testing reproducible as cookies are not stored permanently.

I have added context managers that gracefully cleans up the chrome service if the Browser instance is removed. It is also possible to start a Browser using a with statement.

iiLaurens commented 6 years ago

Unfortunately I cannot get the tests to work with the automatically generated chrome instance if no service url is given. However I have been able to succesfully execute the tests on my local platforms (Windows 10, Ubuntu 18.04). It seems to me that this is something with the travis environment used for testing. If anyone can figure why the automated testing fails and fix it, we can add proper tests for my commits.

codecov[bot] commented 6 years ago

Codecov Report

Merging #25 into master will decrease coverage by 8.35%. The diff coverage is 76.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #25      +/-   ##
==========================================
- Coverage   93.36%   85.01%   -8.36%     
==========================================
  Files           4        6       +2     
  Lines         211      387     +176     
  Branches       21       40      +19     
==========================================
+ Hits          197      329     +132     
- Misses          7       39      +32     
- Partials        7       19      +12
Impacted Files Coverage Δ
pychrome/tempdir.py 55.1% <55.1%> (ø)
pychrome/browser.py 90.19% <81.81%> (-7.37%) :arrow_down:
pychrome/service.py 85.47% <85.47%> (ø)
pychrome/tab.py 90.78% <0%> (-0.66%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3265932...ddab5b9. Read the comment docs.