I am writing Automation Test Scripts for Appian Screens using Selenium and Cucum

I am writing Automation Test Scripts for Appian Screens using Selenium and Cucumber. In the Screens, there are components like Date Field, Radio Button, Check boxes. Facing Issues to find a unique identifier for these components.Tried using Id, ClassName, XPath, but it didn’t work.Issue is that when the Appian screen is developed, the components do not have any identifier unlike JSP pages. These components when rendered on a browser, it converts to html.When html didn’t find any identifier, it creates a new identifier each time. So the identifier is not constant. ClassName is same for all the similar components. XPath is not uniquely traversing to the component. Consider a Radio Button which has Yes and No as an Option HTML Code : <div class="GG51K-MDGB"><div class="aui_FieldLayout_InputContainer"><div class="aui-RadioButtonGroup"><span class="gwt-RadioButto...

OriginalPostID-144422

OriginalPostID-144422

  Discussion posts and replies are publicly visible

  • ...n GG51K-MDHLC GG51K-MDH1"><input checked="" tabindex="0" id="gwt-uid-14802" value="on" name="gwt-uid-14799" type="radio"><label for="gwt-uid-14802">Yes</label></span><span class="gwt-RadioButton GG51K-MDHLC GG51K-MDH1"><input tabindex="0" id="gwt-uid-14803" value="on" name="gwt-uid-14799" type="radio"><label for="gwt-uid-14803">No</label></span></div></div> The Yes and No Options are defined in separate span’s. The Id is randomly generated. Class is common for all the radio buttons. Please suggest me a way to solve this issue.
  • 0
    Certified Lead Developer
    Using the xpath you can select nth element with position(). As long as your forms are always ordered the same way (or are predictable in all of their changes), then you should still be able to find them with xpath.
  • Hello,

    When using Xpath, confirming the Xpath script is very important to make sure that Selenium IDE, WebDriver or Selenium RC can identify the xpath locator during the test.

    QA Engineers can use Xpath Checker to confim xpath. Xpath Checker needs to be installed on Firefox because it is an add on.

    For example, on Wikipedia page, there is a link named "English". When using xpath, we can use the script below.

    xpath=//div/a[text()="English"]

    Thanks.

  • Hello

    It is a best practice to have dedicated test users created within Appian course based on the roles you are testing. Most Appian end-users are set up as basic users so they can only see relevant and contextual data in enterprise environments. However, Appian Designers usually have system administrator privileges, so permissions errors and similar misconfigurations can be missed if we don’t test using roles that have limited permissions.

  • Instead of relying solely on attributes like id or class, you can try to identify elements based on their text content. For example, in your case, you have a radio button with options "Yes" and "No." You could use a CSS selector or XPath that targets these radio buttons based on their labels.

    // Example CSS selector
    WebElement radioButtonYes = driver.findElement(By.cssSelector("span.gwt-RadioButtonLabel:contains('Yes')"));
    
    // Example XPath
    WebElement radioButtonNo = driver.findElement(By.xpath("//span[@class='gwt-RadioButtonLabel'][contains(text(), 'No')]"));
    

    Also, you can use relative XPath expressions (read here- mlops training) that are based on the known surrounding elements or structures. This can make your XPath more robust against changes in the HTML structure.

    WebElement radioButtonYes = driver.findElement(By.xpath("//div[@class='aui-RadioButtonGroup']//span[contains(text(), 'Yes')]"));