[FEATURE] add support for DOM tree relevant assertions made with Kotlintest
skrape{it} should support well-known assertion libraries by adding custom matchers that are relevant when expecting things in the DOM tree. KotlinTest is a well-known testing and assertion library we want to support.
Please add the following custom matchers that can be used on Element objects
- shouldBePresent
- shouldNotBePresent
- shouldBePresentTimes(n)
- shouldHaveText("")
- shouldHaveTextContainig("")
- shouldHaveTextStartingWith("")
- shouldHaveTextEndingWith("")
- shouldHaveClass("")
- shouldHaveClassContainig("")
- shouldHaveClassStartingWith("")
- shouldHaveClassEndingWith("")
- shouldHaveAttribute("" to "")
- shouldHaveId("")
- shouldHaveIdContainig("")
- shouldHaveIdStartingWith("")
- shouldHaveIdEndingWith("")
- shouldBeDisabled
- check if element has attribute disabled
- shouldHaveSrc("")
- shouldHaveSrcContaining("")
- shouldHaveSrcStartingWith("")
- shouldHaveSrcEndingWith("")
- shouldHaveTitle("")
- shouldHaveTitleContainig("")
- shouldHaveTitleStartingWith("")
- shouldHaveTitleEndingWith("")
- shouldHaveHref("")
- shouldHaveHrefContainig("")
- shouldHaveHrefStartingWith("")
- shouldHaveHrefEndingWith("")
@skrapeit do you think it's better to add them here or in the KotlinTest lib?
If the KotlinTest project maintainers will accept to support skrape.it with custom assertions this would be awesome and preferred. If not I guess it's OK if skrape.it will provide the custom matchers itself
@skrapeit just open an issue there. I already implemented some matchers in the lib, and if they feel comfortable with adding jsoup matchers, I can do this one.
Edit: @skrapeit can you assign me this task? I'll start it today, I believe I can finish it till the end of the week.
@christian-draeger whats the meaning of shouldBePresent? How do I check it?
Edit: I already opened a PR with draft status. You can follow the development of the matchers here. The specific matchers for the skrape lib I will open after finishing the basics from the Jsoup.
Nice :) thx a lot
Element.shouldBePresent assertion should fail if a given element is not present in the Document.
@skrapeit I'm not too much available as I wanted to continue developing those matchers. So, I'll remove the WIP from the PR. As soon as they approve, the main structure will be done to add new matchers as needed.