Code Monkey home page Code Monkey logo

core's Introduction

CI/CD Maven Central GitHub top language codecov License EO principles respected here

logo

XpathQS

A library for building Xpath queries in an OOP style. In a JOOQ way, but for the XPATH.

Usage

Apache Maven

<dependency>
  <groupId>org.xpathqs</groupId>
  <artifactId>core</artifactId>
  <version>0.0.7</version>
</dependency>

Gradle Kotlin DSL

implementation("org.xpathqs:core:0.0.7")

Gradle Groovy DSL

implementation 'org.xpathqs:core:0.0.7'

Quick Example

Simple selector with tag and text:

tagSelector("div").text("demo").toXpath()

Will return such XPATH query:

//div[text()='test']

Selector with tag, text contains, and position:

tagSelector("div").text("test", contains = true)[2].toXpath()

Result:

//div[contains(text(), 'test') and position()=2]

For more examples you can discover unit tests.

Immutability

...

Coding conventions

  1. One line per func call

Unit Tests notation

Self Documentation

Each public method should:

  • contain java-doc
  • have a contract and requirements
  • have a link to the unit-tests associated with a concrete requirement

License

This XpathQS lib is released under the MIT License.

core's People

Contributors

github-actions[bot] avatar nachg avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

core's Issues

Add selector factory

Instead of creating selectors in such way:
Selector( props = SelectorProps(tag = "inner") )
It should be able to do it via factory:
tagSelector("inner"

Fix parsing of object-classes inherited from Block classes

There are some Parser errors with a such code

open class HolderWithArgs(
    base: Selector,
    val sel1: BaseSelector,
    val sel2: BaseSelector
): Block(base)

object PageWithBlockMembers : Block(tagSelector("base")) {
    val holder1 = SomeHolder()
    val holder2 = SomeHolder()
}

Implement Package upload

It should be able to upload .jar files as a package, to the github packages, and to the maven

Add ability to compose selectors

It should be able to merge selectors via "|" oparator, or with compose function.

Example:

(tag("div") | tag("p")).toXpath()

should print: //div | //p

Implement Ability to work with nested classes and class-objects

Now we support only one-level POMs:

object Page_NoBase: Block() { val s1 = Selector(props = SelectorProps(tag = "s1")) }

It should be able to work with such POMs as:

object Page_NoBase: Block() { val s1 = Selector(props = SelectorProps(tag = "s1")) object InnerObject: Block() { } }

Add JavaDoc

Add JavaDoc to the public methods and classes

Fix problem of inner objects

When:

object L1: Block(tagSelector("l1")) {
        object L2: Block() {
            object L3: Block(tagSelector("l3")) {
                val s = tagSelector("div")
            }
        }
    }

Then L3 xpath should include L1

Add ability to merge selectors

Here are some examples of how it should work

val s1 = tagSeletor("div")
val s2 = tagSeletor("div")

s1 + s2 //xpath  -  //div//div
s1 `/` s2 //xpath - //div/div
s1 `//` s2.prefix("/") //xpath - //div/div

Add SingleBase annotation

Add a SingleBase annotation, to specify the way how the base selector is linked with a parent. By default it is - "//".
With the SingleBase - it should linked with "/"

Add ability to query parameters

It should be able to create a parameterized query to the selector:

textSelector("OK")
should return: //*[text()='OK']

tagSelector("div").text("OK")
should return: //div[text()='OK']

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.