konveyor / tackle-test-generator-core

Apache License 2.0
28 stars 21 forks source link

dont_click.element exclude all children of all tags #135

Closed w3dkramer closed 2 years ago

w3dkramer commented 2 years ago

Describe the bug

Instead of don'tClickChildrenOf, the dont_click.element specification item is being used with the under_xpath option. I wanted to exclude all children, no matter the type of tag, so I specified

[[dont_click.element]]
  under_xpath = //div[@id='ibm-masthead']//*

and got the exception:

[2022-03-21 12:21:16] [SEVERE ] [org.konveyor.tackletest.ui.crawljax.CrawljaxRunner main] Error creating Crawljax configuration: Tag name cannot be null 
java.lang.NullPointerException: Tag name cannot be null
        at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:895)
        at com.crawljax.core.configuration.CrawlActionsBuilder.dontClick(CrawlActionsBuilder.java:143)
        at com.crawljax.core.configuration.CrawlRules$CrawlRulesBuilder.dontClick(CrawlRules.java:319)
        at org.konveyor.tackletest.ui.crawljax.CrawljaxRunner.handleClickablesElementSpec(CrawljaxRunner.java:215)
        at org.konveyor.tackletest.ui.crawljax.CrawljaxRunner.updateClickablesConfiguration(CrawljaxRunner.java:247)
        at org.konveyor.tackletest.ui.crawljax.CrawljaxRunner.createCrawljaxConfiguration(CrawljaxRunner.java:497)
        at org.konveyor.tackletest.ui.crawljax.CrawljaxRunner.main(CrawljaxRunner.java:645)
sinha108 commented 2 years ago

@w3dkramer: dont_click.element specifications must contain a tag name; they can optionally restrict the tag occurrences with under_xpath, with_text, or with_attribute qualifiers. We do not support specs that contain only the qualifiers without any tag; e.g.

[[dont_click.element]]
  under_xpath = //div[@id='ibm-masthead']//*

For examples, see https://github.com/konveyor/tackle-test-generator-core/blob/main/tackle-test-generator-ui/test/data/sample/tkltest_ui_clickables_config.toml#L33-L68

w3dkramer commented 2 years ago

@sinha108 What would I do to prevent clicking on all types of tags that occur in the children of the xpath? Is it necessary to specify duplicates of

[[dont_click.element]]
  tag= $X
  under_xpath = //div[@id='ibm-masthead']//*

where $X = button, input, a, etc.?

sinha108 commented 2 years ago

@w3dkramer: Currently, yes, you would have one dont_click element for each tag. We can look into enhancing the spec to support multiple tags (e.g., tag = ["button", "input", "a"]), which would make the spec simpler in cases where all tags have the same under_xpath/with_text/with_attribute qualifier. Completely omitting the tag would be harder because the Crawljax API doesn't support specifying element qualifiers without a tag.

w3dkramer commented 2 years ago

Understood. I can work with the spec as it is at the moment, specifying each tag individually, but would definitely be in support of the enhancement to list multiple tags. In theory maybe there could also be a way to specify tag = "all_types" or some keyword, which the spec parser could just translate to duplicate the dont_click element for some predefined list of all types of tags to exclude. In the meantime thank you for illuminating the error.

sinha108 commented 2 years ago

@w3dkramer: Support for list of strings for tag_name has been added: tag_name can now be either a string or a list of strings.