Package: python-automation-framework
PAF - Python Automation FrameworkPython implementation ofTesterraAPI.It is basically a wrapper for SeleniumWebDriverandWebElementwhich brings some more comfort features.
This is not a test framework, but it implements assertion features anyway.The basic concept is, to identifyWebElementson every action or property accessor to preventStaleElementExceptions.Quick startimportinjectimportpaf.configfrompaf.locatorimportByfrompaf.pageimportFinderPage,PageFactory# Configure dependency injectioninject.configure(paf.config.inject)# Instantiate the page factorypage_factory=inject.instance(PageFactory)# Create a simple finder pagepage=page_factory.create_page(FinderPage)# Visit URLpage.open("https://google.com")# Find elementelement=page.find("#q")# Perform actionselement.type("Search")# Perform assertionselement.expect.text.be("Search")PrerequisitesYou need at least a localWebDriverinstalled.brew|choco|aptinstallchromedriverPython 3.10 (or higher).Feature listUiElementsLocatorsPage objectsComponentsManaging WebDriversExecution controllingInject listenerMissing features (tdb)Rect assertionsShadowRoot supportDrag & Drop over framesEnvironment variablesPAF_BROWSER_SETTING=chrome:90: Sets the requested browser name and it's version.PAF_WINDOW_SIZE=1920x1080: Sets the browsers default window size.PAF_SCREENSHOTS_DIR=screenshots: Sets the screenshots' directory.PAF_SEQUENCE_WAIT_AFTER_FAIL=0.3: Wait in seconds whenever a sequence action fails.PAF_SEQUENCE_RETRY_COUNT=3: Retry count for every sequence action.PAF_DEMO_MODE=0: Enables the demo mode by highlighting actions and assertions.PAF_SELENIUM_SERVER_URL=http://127.0.0.1:4444: Uses Selenium server if set.ExamplesSome real world examples.test_google.py: is a regular Google search, implemented withPage ObjectsandComponents.test_todo_mvc.py: are re-implemented test cases from theRobot Framework TodoMVCexample. It's IMHO developer friendly, better readable and less code.test_asyncio.py: Parallel execution viaasyncio.ComparisonComparison of the syntax with other frameworks.Pyleniumpy.get("a[href='/about']").should().have_text("About")find("a[href='/about']").expect.text.be("About")SeleniumBaseself.assert_text_not_visible("Thanks for your purchase.","#app .success")find("#app .success").expect.text.not_be("Thanks for your purchase.")Selenebrowser.all('#rso>div').should(have.size_greater_than(5))\.first.should(have.text('Selenium automates browsers'))div=find("#rso>div")div.expect.count.greater_than(5).be(True)div.first.expect.text.be("Selenium automates browsers")References:https://www.nextgenerationautomation.com/post/python-test-automation-frameworksDeveloper areaTestingRun the tests on you local machinepytest--cov=paf-n=4testBuild test base container (for use in GitHub Actions)podmanbuild-fubuntu-base.Dockerfile--arch=amd64-tpaf-test-base:latestsourcebuild.envecho$DOCKER_CONTAINER_REGISTRY_TOKEN|podmanlogin-umreiche--password-stdinghcr.io
podmanpushpaf-test-base:latestdocker://ghcr.io/mreiche/paf-test-base:chrome-116Build test runner container (for testing)podmanbuild-ftest.Dockerfile--arch=amd64-tpaf-test:latestRun tests within containerpodmanrun-ePAF_TEST_HEADLESS=1-ePAF_TEST_CONTAINER=1-ePAF_TEST_LOCAL_SELENIUM=0paf-test:latestpytest--cov=paf-n=4testRun local selenium serverwgethttps://github.com/SeleniumHQ/selenium/releases/download/selenium-4.9.0/selenium-server-4.9.0.jar-Oselenium-server.jar
java-jarselenium-server.jarstandalone--host127.0.0.1Debug XPaths in Browser's Developer Consolexpath="//dt[.//text()='Title:']/following-sibling::dd[1]"snapshot=document.evaluate(xpath,document.body,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE)snapshot.snapshotItem(0).textContentRelease updateUpdate version insetup.pyPackage librarypythonsetup.pysdistPublish librarytwineuploaddist/python-automation-framework-[version].tar.gzReferenceshttps://stackoverflow.com/questions/64033686/how-can-i-use-private-docker-image-in-github-actionshttps://tecadmin.net/setup-selenium-chromedriver-on-ubuntu/https://stackoverflow.com/questions/46052736/python-proxy-classhttps://chromedriver.chromium.org/