Skip to content

Add "Get All Picklist Values" keyword for Lightning picklists#3986

Open
b-vamsipunnam wants to merge 4 commits into
SFDO-Tooling:mainfrom
b-vamsipunnam:add-get-all-picklist-values
Open

Add "Get All Picklist Values" keyword for Lightning picklists#3986
b-vamsipunnam wants to merge 4 commits into
SFDO-Tooling:mainfrom
b-vamsipunnam:add-get-all-picklist-values

Conversation

@b-vamsipunnam
Copy link
Copy Markdown

@b-vamsipunnam b-vamsipunnam commented May 23, 2026

Summary

Adds a new Robot Framework keyword, Get All Picklist Values, to the Salesforce library.

This keyword makes it easier to retrieve the values currently rendered in Salesforce Lightning picklists directly from the UI.

Motivation

Salesforce Lightning picklists can change due to metadata deployments, admin updates, record type configurations, and environment-specific customization.

In many automation scenarios, validating picklist values currently requires brittle XPath assertions or hardcoded validation logic inside tests.

This keyword provides a reusable way to fetch Lightning picklist values directly from the UI, making validation simpler and easier to maintain.

Implementation

  • Added get_all_picklist_values to cumulusci/robotframework/Salesforce.py
  • Supports required field labels (Stage, *Stage, Stage *)
  • Waits for picklist options to become visible before reading values
  • Handles stale Lightning DOM elements safely
  • Returns the values currently rendered in the Lightning picklist

Use Cases

This keyword helps simplify Salesforce Lightning picklist validation in UI automation scenarios where values may evolve over time.

Examples include:

  • validating newly added picklist values after metadata deployments
  • verifying picklist configurations across different environments
  • detecting missing or removed values after Salesforce admin changes
  • reducing brittle XPath-based assertions in tests
  • smoke testing Lightning forms and modals after configuration updates

Tests

Added Python unit tests covering:

  • rendered picklist value retrieval
  • stale element handling
  • missing picklist handling
  • custom timeout support

Added a Robot Framework integration test validating:

  • real Salesforce Lightning modal interaction
  • Stage picklist value retrieval

Files Changed

  • AUTHORS.rst
  • cumulusci/robotframework/Salesforce.py
  • cumulusci/robotframework/tests/test_salesforce.py
  • cumulusci/robotframework/tests/salesforce/picklist.robot

Example

${values}=    Get All Picklist Values    Stage
Log    ${values}

@b-vamsipunnam b-vamsipunnam requested a review from a team as a code owner May 23, 2026 14:58
@salesforce-cla
Copy link
Copy Markdown

Thanks for the contribution! Before we can merge this, we need @b-vamsipunnam to sign the Salesforce Inc. Contributor License Agreement.

@b-vamsipunnam
Copy link
Copy Markdown
Author

Thanks for the contribution! Before we can merge this, we need @b-vamsipunnam to sign the Salesforce Inc. Contributor License Agreement.

I completed this Step

image

Copy link
Copy Markdown
Contributor

@jstvz jstvz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. A few issues to address:

Context: This module has not seen active locator or keyword development since API v56. If this lands, future maintenance would likely fall to contributors.

XPath injection

The picklist parameter is interpolated directly into XPath via f-strings:

f"normalize-space(.)='{picklist}' "

A label containing a single quote (e.g. Customer's Status) breaks the XPath. Use concat() to handle arbitrary input safely, or at minimum escape quotes.

Empty-string inclusion

The test asserts values == ["Warm", "Cold", "Warm", ""]. The whitespace-only option " " strips to "" and is included in results. Consumers will almost always need to filter these. Consider:

text = element.text.strip()
if text:
    values.append(text)

Mock bleed between tests

TestKeywordGetAllPicklistValues uses a class-level cls.sflib instance but never resets mock state between tests. set_focus_to_element.side_effect = ElementNotFound() in test_raises_assertion_when_picklist_not_found persists into subsequent tests if execution order changes. Use setup_method to reset mocks or create a fresh instance per test.

Bypassed label infrastructure

CCI's robot library has an existing locator/label system (_init_locators, lex_locators). Building a parallel XPath-based label lookup creates a second maintenance surface. Consider whether the existing locator infrastructure can be extended for this use case.

@b-vamsipunnam
Copy link
Copy Markdown
Author

Hi @jstvz ,

Thanks for the detailed review. I’ve updated the PR to address the feedback:

  • Replaced the custom label XPath approach with the existing label: locator strategy, which avoids direct interpolation of the picklist label into XPath and aligns with the current locator infrastructure.
  • Updated value collection to skip whitespace-only option text.
  • Updated the tests to avoid mock side effects leaking across test cases.
  • Kept the implementation aligned with the existing Salesforce label locator system instead of introducing a separate label lookup path.

I also reran the unit tests, Robot test, ruff, and black checks after the changes.

Happy to make any additional updates or refinements if needed. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants