Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Is it possible to validate the current selected option with Parasoft (xpath)

SaskiaPega
SaskiaPega Posts: 5
edited May 2020 in SOAtest

In the code I cannot see which is currently selected and I know that what is selected is send to the server. But I am hoping that there still is a way.

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    Any tools that extract (Data Bank), transform (Transformer), and validate (Assertor), have an "Evaluate XPath" button to help you verify what the XPath expression is doing, in case you think the XPath was incorrect or needs to be changed. The XPath expression that you configure is shown in the UI and you can trust that SOAtest will evaluate it correctly.

    If you are asking specifically about the XML Assertor, you can also see my answer to this other thread: in response (or anywhere) - see values that were asserted

  • jakubiak
    jakubiak Posts: 795 admin

    In HTML, when an option is selected the option tag has a "selected" attribute with no value. You can attempt to validate that the correct option has the "selected" attribute. If no option has a selected attribute, the first one is the one shown by the browser.

  • tony
    tony Posts: 25 ✭✭
    edited May 2020

    To add to what people have said so far, you will probably need to use a CSS selector to find and validate the selected option. In your Browser Validation Tool, for the "Element Locator" choose "XPath" and use the special "css=" prefix to enter a CSS selector. In this case you can use something like: "css=.Example1b option:checked." This will work in more cases than looking for the "selected" attribute, including when there is no "selected" attribute or when the selected option has changed after the page first loaded.

    This assumes you are using the WebDriver engine for playback. The css= prefix will not work in the legacy engine.

  • SaskiaPega
    SaskiaPega Posts: 5

    Thanks everyone. Unfortunately none of these seem to be it for us.