kazurayam / inspectus4selenium-sample-project

A sample project that performs automated Web App UI test on Selenium4 using the Inspectus library
0 stars 0 forks source link

ignored attributes should be painted grey, but actually not #21

Open kazurayam opened 10 months ago

kazurayam commented 10 months ago

In the https://github.com/kazurayam/inspectus4selenium-sample-project/blob/0.5.0/src/test/java/com/kazurayam/inspectus/selenium4sample/AppleTwinsDiffTest.java , LINE#90

                .ignoreMetadataKeys(
                        new IgnoreMetadataKeys.Builder()
                                .ignoreKeys("URL.host", "URL.path",
                                        "URL.protocol", "URL.port",
                                        "image-width", "image-height").build()
                )

So these Keys should be painted grey color in the report. But actually not, as the following:

Screenshot 2023-12-10 at 10 26 31
kazurayam commented 10 months ago

A sample successful case:

Screenshot 2023-12-10 at 11 06 00
<dd>
                    <span>{</span>
                    <span class="ignoring-key">"URL.host":</span>
                    <span>"myadmin.kazurayam.com"</span>
                    <span>, </span>
                    <span>"URL.path":</span>
                    <span>"/"</span>
                    <span>, </span>
                    <span>"URL.protocol":</span>
                    <span>"http"</span>
                    <span>, </span>
                    <span class="ignoring-key">"profile":</span>
                    <span class="matched-value">"MyAdmin_ProductionEnv"</span>
                    <span>, </span>
                    <span>"selector":</span>
                    <span>"body"</span>
                    <span>}</span>
                  </dd>

<span class="ignoring-key">"profile":</span> will be painted grey.

<span class="matched-value">"MyAdmin_ProductionEnv"</span> will be painted green.

kazurayam commented 10 months ago

See https://github.com/kazurayam/materialstore/blob/0.17.2/src/main/java/com/kazurayam/materialstore/core/metadata/MetadataImpl.java Line#51

@Override
    public void annotate(final QueryOnMetadata query,
                         final IgnoreMetadataKeys ignoreMetadataKeys,
                         final IdentifyMetadataValues identifyMetadataValues) {
        Objects.requireNonNull(query);
        Objects.requireNonNull(ignoreMetadataKeys);
        Objects.requireNonNull(identifyMetadataValues);
        Set<String> keys = attributes.keySet();
        keys.forEach( key -> {
            MetadataAttribute attribute = attributes.get(key);
            if (ignoreMetadataKeys.contains(key)) {
                attribute.setIgnoredByKey(true);
            }
            if (canBePaired(query, key)) {
                attribute.setPaired(true);
            }
            if (canBeIdentified(key, identifyMetadataValues)) {
                attribute.setIdentifiedByValue(true);
            }
            //
            Matcher m = SemanticVersionPattern.straightMatcher(this.get(key));
            if (m.matches()) {
                SemanticVersionMatcherResult result = new SemanticVersionMatcherResult(m);
                attribute.setSemanticVersionMatcherResult(result);
            }
        });
    }

This is where the ignoredByKey attribute is set to the QueryOnMetadata object.

kazurayam commented 10 months ago

I traced the call chain from the MetadataImpl#annotate() up to the MaterialProductGroup#add():

Screenshot 2023-12-10 at 11 23 48

I checked how the MaterialProductGroup#add() is used.

Surprising enough, it is used only by tests. Application is not calling it!

This is the reason why the grey painting is not done.