diff --git a/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/steps/integration/ResourceCheckSteps.java b/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/steps/integration/ResourceCheckSteps.java index b903d2bca5..0f78b7965a 100644 --- a/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/steps/integration/ResourceCheckSteps.java +++ b/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/steps/integration/ResourceCheckSteps.java @@ -38,6 +38,7 @@ import org.jbehave.core.model.ExamplesTable; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; +import org.jsoup.select.Selector.SelectorParseException; import org.vividus.html.HtmlLocatorType; import org.vividus.html.JsoupUtils; import org.vividus.http.HttpMethod; @@ -162,7 +163,7 @@ private Optional parseElement(Element element, boolea return Optional.empty(); } - String elementCssSelector = element.cssSelector(); + String elementCssSelector = getCssSelector(element); if (elementUriAsString.isEmpty()) { return Optional.of(ResourceValidationError.EMPTY_HREF_SRC @@ -246,6 +247,18 @@ private static String getElementUri(Element element) return element.attr("src"); } + private String getCssSelector(Element element) + { + try + { + return element.cssSelector(); + } + catch (SelectorParseException exception) + { + return String.format("Unable to build CSS selector for '%s' element", element.tagName()); + } + } + private URI resolveUri(String uri) throws URISyntaxException { URI uriToCheck = new URI(uri); diff --git a/vividus-plugin-web-app-to-rest-api/src/test/java/org/vividus/steps/integration/ResourceCheckStepsTests.java b/vividus-plugin-web-app-to-rest-api/src/test/java/org/vividus/steps/integration/ResourceCheckStepsTests.java index 164d11e810..ae119846f8 100644 --- a/vividus-plugin-web-app-to-rest-api/src/test/java/org/vividus/steps/integration/ResourceCheckStepsTests.java +++ b/vividus-plugin-web-app-to-rest-api/src/test/java/org/vividus/steps/integration/ResourceCheckStepsTests.java @@ -154,6 +154,9 @@ class ResourceCheckStepsTests

Section

Jump link using name

Named Section + """; @@ -228,13 +231,16 @@ void shouldCheckDesiredResourcesAndPostAttachment() throws InterruptedException, @SuppressWarnings(UNCHECKED) Set validationsToReport = ((Map>) m) .get(RESULTS); - assertThat(validationsToReport, hasSize(16)); + assertThat(validationsToReport, hasSize(17)); Iterator resourceValidations = validationsToReport.iterator(); validate(resourceValidations, URI.create(NAMED_SECTION_SELECTOR), JUMP_LINK_USING_NAME_SELECTOR, CheckStatus.PASSED, N_A); validate(resourceValidations, URI.create(SECTION_SELECTOR), JUMP_LINK_SELECTOR, CheckStatus.PASSED, N_A); validate(resourceValidations, SERENITY_URI, HTTP_ID, CheckStatus.PASSED, N_A); validate(resourceValidations, imageUri, "#image", CheckStatus.PASSED, N_A); + validate(resourceValidations, + URI.create("https://docs.vividus.dev/vividus/latest/_images/subscribe-to-releases.gif"), + "Unable to build CSS selector for 'img' element", CheckStatus.PASSED, N_A); validate(resourceValidations, EXTERNAL_SECTION_LINK, EXTERNAL_SECTION_LINK_SELECTOR, CheckStatus.PASSED, N_A); validate(resourceValidations, gifImageUri, "html > body > img.image.\\(gif\\)",