{"id":18510037,"url":"https://github.com/lfex/lse","last_synced_at":"2025-10-11T04:34:47.177Z","repository":{"id":30728467,"uuid":"34284734","full_name":"lfex/lse","owner":"lfex","description":"Selenium support for ltest, the LFE testing framework","archived":false,"fork":false,"pushed_at":"2015-04-29T22:18:14.000Z","size":172,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-14T11:17:45.932Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Erlang","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/lfex.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":"2015-04-20T20:31:00.000Z","updated_at":"2015-04-29T22:18:14.000Z","dependencies_parsed_at":"2022-09-09T01:42:15.509Z","dependency_job_id":null,"html_url":"https://github.com/lfex/lse","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lfex/lse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfex%2Flse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfex%2Flse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfex%2Flse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfex%2Flse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lfex","download_url":"https://codeload.github.com/lfex/lse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfex%2Flse/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263427305,"owners_count":23464842,"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":[],"created_at":"2024-11-06T15:20:18.514Z","updated_at":"2025-10-11T04:34:42.126Z","avatar_url":"https://github.com/lfex.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lse\n\n*Selenium support for ltest, the LFE testing framework*\n\n\u003cimg src=\"resources/images/se-logo.png\" /\u003e\n\n## Table of Contents\n\n* [Introduction](#introduction-)\n* [Installation](#installation-)\n* [Usage](#usage-)\n  * [From the REPL](#from-the-repl-)\n  * [In a Test Suite](#in-a-test-suite-)\n  * [Running a Suite](#running-a-suite-)\n\n\n## Introduction [\u0026#x219F;](#table-of-contents)\n\nThis library offers a light-weight lispy-wrapper around the\n[Erlang Selenium webdriver](https://github.com/Quviq/webdrv). In order to use\nltest's support of Selenium, you will need to have the latest development\nreleaase of [lfetool](https://github.com/lfe/lfetool/tree/dev-v1#dev-)\ninstalled.\n\n\n## Installation [\u0026#x219F;](#table-of-contents)\n\nJust add it to your ``rebar.config`` deps:\n\n```erlang\n  {deps, [\n    ...\n    {lse, \".*\",\n      {git, \"git@github.com:lfex/lse.git\", \"master\"}}\n      ]}.\n```\n\nAnd then do the usual:\n\n```bash\n    $ make compile\n```\n\n\n## Usage [\u0026#x219F;](#table-of-contents)\n\nThe Selenium macros available in ``include/lse-macros.lfe`` and the\nSelenium functions in ``src/lse.lfe`` are generated with\n[kla](https://github.com/lfex/kla), and have thus taken advantage of the feature\nthat converts underscores in the Erlang source library to dashes in the wrapped\nLFE library.\n\nIf you have your Chrome web browser in a non-standard location, tests against\nthe webdriver will fail. You will need to symlink your browser to the expected\nlocation or pass options in the capabilities data structure (see the\nchromedriver docs for that).\n\n\n### From the REPL [\u0026#x219F;](#table-of-contents)\n\n```cl\n\u003e (lse:start-session\n    'se-session\n    \"http://localhost:9515/\"\n    (lse:default-chrome)\n    10000))\n#(ok \u003c0.46.0\u003e)\n\u003e (lse:set-url 'se-session \"http://google.com\")\nok\n\u003e (lse:get-page-title 'se-session)\n#(ok \"Google\")\n\u003e (set `#(ok ,elem) (lse:find-element 'se-session \"name\" \"q\"))\n#(ok \"0.12670360947959125-1\")\n\u003e (lse:send-value 'se-session elem \"LFE\")\nok\n\u003e (lse:submit 'se-session elem)\nok\n\u003e (lse:get-page-title 'se-session)\n#(ok \"LFE - Google Search\")\n```\n\n\n### In a Test Suite [\u0026#x219F;](#table-of-contents)\n\nHere is some sample usage from a test module (with the ``lselenium``\nbehaviour):\n\n```lisp\n(defmodule lselenium-tests\n  (behaviour lselenium)\n  (export all))\n\n(include-lib \"ltest/include/ltest-macros.lfe\")\n(include-lib \"lse/include/lse-macros.lfe\")\n\n(defun get-session ()\n  'lselenium-session)\n\n(defun start-session ()\n  (lse:start-session\n    (get-session)\n    \"http://localhost:9515/\"\n    (lse:default-chrome)\n    10000))\n\n(defun set-up ()\n  (prog1\n    (case (start-session)\n      (`#(ok ,pid) pid)\n      (x x))\n    (timer:sleep 3000)))\n\n(defun tear-down (pid)\n  (lse:stop-session (get-session)))\n\n(deftestcase google-site-page-title (pid)\n  (lse:set-url (get-session) \"http://google.com\")\n  (is-equal #(ok \"Google\") (lse:get-page-title (get-session))))\n\n(deftestcase google-submit-search (pid)\n  (lse:set-url (get-session) \"http://google.com\")\n  (let ((`#(ok ,elem) (lse:find-element (get-session) \"name\" \"q\")))\n    (lse:send-value (get-session) elem \"LFE AND Lisp\")\n    (lse:submit (get-session) elem)\n    (timer:sleep 1500)\n    (is-equal #(ok \"LFE AND Lisp - Google Search\")\n              (lse:get-page-title (get-session)))))\n\n(deftestgen foreach-test-suite\n  (tuple\n    'foreach\n    (defsetup set-up)\n    (defteardown tear-down)\n    (deftestcases\n      google-site-page-title\n      google-submit-search)))\n```\n\nNote that for now, only ``foreach`` fixtures are supported.\n\n### Running a Suite [\u0026#x219F;](#table-of-contents)\n\nTo run selenium tests, you will need to:\n\n* start the Chrome driver\n* run the selenium tests\n* stop the Chrome driver\n\nYou'll probably want to add ``make`` targets for these, something\nlike the following:\n\n\n```Makefile\n$(CHROMEDRIVER):\n    mkdir -p bin\n    cd bin \u0026\u0026 \\\n    curl -O http://chromedriver.storage.googleapis.com/2.9/chromedriver_mac32.zip \u0026\u0026 \\\n    unzip chromedriver_mac32.zip\n\nstart-chromedriver: $(CHROMEDRIVER)\n    -@$(CHROMEDRIVER) --verbose \u0026\n\nstop-chromedriver:\n    @ps aux|grep $(CHROMEDRIVER)|grep -v grep|awk '{print $$2}'|xargs kill -15\n\ncheck-selenium-only:\n    @clear\n    @PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) \\\n    erl -cwd \"`pwd`\" -listener ltest-listener -eval \\\n    \"case 'ltest-runner':selenium() of ok -\u003e halt(0); _ -\u003e halt(127) end\" \\\n    -noshell\n\ncheck-selenium: clean-eunit compile-tests check-selenium-only\n\ncheck-all: get-deps clean-eunit compile-no-deps\n    PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) tests all\n    make check-selenium-only\n```\n\nUsing the make targets defined above:\n\n* in one terminal window execute ``make start-chromedriver``\n* in another, execute ``make check-selenium``\n* when you are done testing, you can execute ``stop-chromedriver``\n\nOutput should look something like the following:\n\n```\n================================ ltest =================================\n\n---------------------------- Selenium Tests ----------------------------\n\nmodule: unit-lse-tests\n  google_site_page_title_test_case .................................. [ok]\n  google_site_page_title_test_case .................................. [ok]\n  google_submit_search_test_case .................................... [ok]\n  google_submit_search_test_case .................................... [ok]\n  time: 19563ms\n\nsummary:\n  Tests: 4  Passed: 4  Skipped: 0  Failed: 0 Erred: 0\n  Total time: 19563ms\n\n\n========================================================================\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flfex%2Flse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flfex%2Flse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flfex%2Flse/lists"}