Package: c4t
c4t: Chrome for Testing - v1.2.0InstallChrome for Testingassets. A flavor of Chrome, specifically for testing and a matching chromedriver. The version of assets installed are from the stable channel and currently only forlinux64platforms.Why Chrome for Testing?Taken fromthe Chrome Developers Blog...setting up an adequate browser testing environment is notoriously difficult...You want consistent, reproducible results across repeated test runs—but this may not happen if the browser executable or binary decides to update itself in between two runs.You want to pin a specific browser version and check that version number into your source code repository, so that you can check out old commits and branches and re-run the tests against the browser binary from that point in time.Not only do you have to download a Chrome binary somehow, you also need a correspondingly-versioned ChromeDriver binary to ensure the two binaries are compatible.Chrome for Testing is a dedicated flavor of Chrome targeting the testing use case, without auto-update, integrated into the Chrome release process, made available for every Chrome release...finding a matching Chrome and ChromeDriver binary can be completely eliminated by integrating the ChromeDriver release process into the Chrome for Testing infrastructure.InstallationFrom PyPI(venv)$pipinstallc4t(venv)$From GitHub(venv)$pipinstallgit+https://github.com/p4irin/c4t.git(venv)$VerifyIn a REPLShow version(venv)$python
Python3.8.10(default,Jun22021,10:49:15)[GCC9.4.0]onlinux
Type"help","copyright","credits"or"license"formoreinformation.
>>>importc4t
>>>c4t.__version__'<major>.<minor>.<patch>'>>>Or on the command lineShow version(venv)$c4t--version
v1.1.0(venv)$Display package documentation(venv)$python-mpydocc4t(venv)$UsageIn codeInstall the default, the latest stable version and use it with SeleniumPython3.8.10(default,May262023,14:05:08)[GCC9.4.0]onlinux
Type"help","copyright","credits"or"license"formoreinformation.
>>>importc4t
>>>assets=c4t.Assets()Create"assets"directory.
>>>assets.install()Createdirectory./assets/117.0.5938.62
Downloadingchrome-linux64.zip.100%[......................................................................]146689409/146689409Downloadingchromedriver-linux64.zip.100%[..........................................................................]7508443/7508443Unzippingchrome-linux64.zip
Unzippingchromedriver-linux64.zip
Creatingsymlinktochromeversion117.0.5938.62
Creatingsymlinktochromedriverversion117.0.5938.62
Finishedinstallingversion117.0.5938.62ofChromeforTestingandChromedriver.
-------------------------------------------
Version117.0.5938.62istheactiveversion
-------------------------------------------
>>>fromselenium.webdriverimportChromeOptions,ChromeService,Chrome
>>>options=ChromeOptions()>>>options.binary_location=c4t.location.chrome
>>>service=ChromeService(executable_path=c4t.location.chromedriver)>>>browser=Chrome(options=options,service=service)>>>browser.get('https://pypi.org/user/p4irin/')>>>browser.close()>>>browser.quit()>>>On the command lineDisplay command line help(venv)$c4t--help(venv)$c4tinstall--helpInstall the default, the latest stable version(venv)$c4tinstallInstall a specific version(venv)$c4tinstall--version116.0.5794.0Show the currently active version(venv)$c4t--activeReferenceBlogGitHub