{"id":19719946,"url":"https://github.com/timboudreau/giulius-selenium-tests","last_synced_at":"2025-04-29T21:30:42.652Z","repository":{"id":7903289,"uuid":"9284492","full_name":"timboudreau/giulius-selenium-tests","owner":"timboudreau","description":"A test harness that allows Selenium tests to be run using JUnit and test fixtures to be created and injected by a WebDriver-aware Guice","archived":false,"fork":false,"pushed_at":"2023-05-03T08:37:09.000Z","size":185,"stargazers_count":12,"open_issues_count":0,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-05T19:23:45.207Z","etag":null,"topics":["fixtures","guice","junit","selenium"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timboudreau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-07T22:42:31.000Z","updated_at":"2021-12-20T07:12:23.000Z","dependencies_parsed_at":"2023-01-13T14:33:16.201Z","dependency_job_id":null,"html_url":"https://github.com/timboudreau/giulius-selenium-tests","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timboudreau%2Fgiulius-selenium-tests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timboudreau%2Fgiulius-selenium-tests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timboudreau%2Fgiulius-selenium-tests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timboudreau%2Fgiulius-selenium-tests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timboudreau","download_url":"https://codeload.github.com/timboudreau/giulius-selenium-tests/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251585739,"owners_count":21613270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fixtures","guice","junit","selenium"],"created_at":"2024-11-11T23:09:46.909Z","updated_at":"2025-04-29T21:30:42.415Z","avatar_url":"https://github.com/timboudreau.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"giulius-selenium-tests\n======================\n\nAn easy way to write Selenium tests in Java, have objects representing web page contents be created and injected by Guice + WebDriver, and use any JUnit reporting engine with Selenium\n\nBuilds and a Maven repository containing this project can be \u003ca href=\"https://timboudreau.com/builds/\"\u003efound on timboudreau.com\u003c/a\u003e.\n\nOverview\n--------\n\nThis library makes it easy to\nwrite Selenium tests in Java.  These tests are run using JUnit (which\nmakes reporting simple). \nIt can utilize both [Google Guice](http://code.google.com/p/google-guice/)\nand Selenium's own injection to create test fixtures.  It extends \n[Giulius-Tests](https://github.com/timboudreau/giulius-tests), a test-harness\nfor writing Guice-aware JUnit tests to make the framework Selenium-aware as well.\n\nThis means that\ntest methods can have method parameters, and the framework will pre-create\nobjects that you want to test.  You write test code to test what\nmatters, and the framework does the rest.\n\nTo see what these tests look like, check out [this test](https://github.com/timboudreau/giulius-selenium-tests/blob/master/selenium/src/test/java/com/mastfrog/selenium/TestSeleniumTest.java) which is part of the test-suite for this project.\n\nHere's a test which tests a fake search page.  That page contains\na form with a text field with the ID ``searchField``, a submit button with the ID\n``searchSubmit`` and a span with the ID ``prev`` which contains the previously\nsubmitted form.  This test uses a _test fixture_ - a class called \n``MyPageModel`` which contains fields representing each of those HTML\nelements.\n\nThe nice thing about this is that you never have to write code to create\nany of the objects in question - the framework creates them for you.  So\nwriting tests remains focused on writing code that actually tests something:  \n\n    @Test\n    @Fixtures( LoginFixture.class ) // do the login steps ahead of time\n    public void foo( MyPageModel page, WebDriverWait wait ) {\n        page.searchField.sendKeys ( \"giulius\" );\n        page.searchButton.click ();\n        assertEquals ( \"giulius\", page.prev.getText() );\n    }\n\nMyPageModel is a Selenium model for the content of the page, written just\nthe way you normally do with Selenium tests.\n\nThe difference is that the framework sees that this class is an\nargument to your test method, and it scans its fields and notices that there\nare Selenium annotations on them.  So it uses Selenium's [PageFactory](http://selenium.googlecode.com/svn/trunk/docs/api/java/index.html?org/openqa/selenium/support/PageFactory.html) to instantiate the object, and then uses Guice to inject any other objects\nyou might have included in it (remember to use ``@Inject`` on such fields).\n\nThe result is that you never have to write code to instantiate this class\nourselves - you just mention it as a test method parameter and the rest is\nhandled for you.\n\n    public class MyPageModel {\n        @FindBy(how = How.ID, using = \"searchField\")\n        @CacheLookup\n        public WebElement searchField;\n        @FindBy(how = How.ID, using = \"searchSubmit\")\n        public WebElement searchButton;\n        @FindBy(how = How.ID, using = \"prev\")\n        public WebElement prev;\n    }\n\nYou may have noticed the annotation:\n\n    @Fixtures (LoginFixture.class)\n\nThat annotation is a way of saying \"I don't need one of these passed to me, \nbut I need you to make one before my test method runs\".  The test harness\nwill construct an instance of ``LoginFixture``.  As a side-effect of constructing\nit, it logs into the web page, so that the page is ready to do the things\nwe want to test.\n\n\nGroovy\n------\n\nThe `groovy-selenium-guice-demo` shows an example of writing Selenium tests injected by Guice\nin Groovy and run in JUnit, and recording a screen-capture video while doing so (requires\n`ffmpeg`).\n\nThe `test-main` project provides a simplified JUnit runner suitable for running tests\nas a standalone process (Selenium tests are not usually part of a unit test suite).\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimboudreau%2Fgiulius-selenium-tests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimboudreau%2Fgiulius-selenium-tests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimboudreau%2Fgiulius-selenium-tests/lists"}