{"id":22360378,"url":"https://github.com/sergueik/selector_validators","last_synced_at":"2026-05-04T03:35:47.566Z","repository":{"id":80959385,"uuid":"162040053","full_name":"sergueik/selector_validators","owner":"sergueik","description":"exercises the grammar checks of string to recognize it a valid cssSelector or a valid XPath","archived":false,"fork":false,"pushed_at":"2023-09-20T11:22:11.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T14:31:59.445Z","etag":null,"topics":["lexer","selenium","webdriver"],"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/sergueik.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-16T20:53:29.000Z","updated_at":"2021-12-14T02:01:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"d52f91c0-d59b-4d04-85c8-7f0b35dc4ac8","html_url":"https://github.com/sergueik/selector_validators","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sergueik/selector_validators","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergueik%2Fselector_validators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergueik%2Fselector_validators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergueik%2Fselector_validators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergueik%2Fselector_validators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sergueik","download_url":"https://codeload.github.com/sergueik/selector_validators/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergueik%2Fselector_validators/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32593945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"online","status_checked_at":"2026-05-04T02:00:06.625Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["lexer","selenium","webdriver"],"created_at":"2024-12-04T16:16:05.664Z","updated_at":"2026-05-04T03:35:47.549Z","avatar_url":"https://github.com/sergueik.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Info\n\nThese projects exercises the grammar checks of string to recognize it a valid __cssSelector__ or a valid __XPath__. \nThe token construction was based on utilities found in\n[CSS Selector to XPath Converter Java tool](https://github.com/sam-rosenthal/java-cssSelector-to-xpath) and simplifid since no deep capturing is needed for validation, \njust a grammar end state. Later the XPath tokenization grammar was created based on the cssSelector one \n(no token aliadation exist at).\n\n### Grammar \n\nThe regexp below is all that is needed tovalidate the \n  * cssSelector\n```java\nTOKEN_EXTRACTOR = \"^([^ ~+\u003e\\\\[]*(?:\\\\[[^\\\\]]+\\\\])*)($|\\\\s*[ ~+\u003e]\\\\s*[^ ~+\u003e\\\\[].*$)\";\n```\n```java\nCSS_ATTRIBUTE_CONDITION_EXTRACTOR = \"(?i)^(-?[_a-z]+[_a-z0-9-]*|\\\\*)?(#[_a-z0-9-]*)?(\\\\.[_a-z0-9-]*)?(:[a-z][a-z\\\\-]*\\\\([^)]+\\\\))?(\\\\[\\\\s*-?[_a-z]+[_a-z0-9-]*\\\\s*(\\\\=|\\\\~=|\\\\|=|\\\\^=|\\\\$=|\\\\*=)?\\\\s*([\\\"'][-_.#a-z0-9:\\\\/ ]+[\\\"']|[-_.#a-z0-9:\\\\/]+)?\\\\s*\\\\])*$\";\n```\n  * Xpath\n```java\nTOKEN_EXTRACTOR = \"^\\\\s*(/?/?\\\\s*[^ /\\\\[]+(?:\\\\[[^\\\\]]+\\\\])*)($|\\\\s*//?\\\\s*[^ /\\\\[]+.*$)\";\n```\n### TODO\n\nThe cssSelector validator does not recognize atttibute negation semantics, often found in locating of invisible elements in the page:\n\n```java\ninput:not([class*='disabled'])\n```\nor\n```java\n#id:not([class*='disabled'])\n```\n### License\nThis project is licensed under the terms of the MIT license.\n\n### Author\n[Serguei Kouzmine](kouzmine_serguei@yahoo.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergueik%2Fselector_validators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsergueik%2Fselector_validators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergueik%2Fselector_validators/lists"}