#3946: Add Salesforce unique selectors
What does this PR do?
- Closes #3946
Discussion
@fregante Is there any specific reason that you added data-aura-rendered-by to UNSTABLE_SELECTORS list here?
Checklist
- [ ] Designate a primary reviewer
@twschiller @fregante I created PR here and still need to polish more however I'd like to hear feedback from you about this PR.
@fregante Is there any specific reason that you added
data-aura-rendered-bytoUNSTABLE_SELECTORSlist here?
You can find out by following the commit on that line:
https://github.com/pixiebrix/pixiebrix-extension/commit/e7f1c6e96d1e3df96252797472898e3d1c3fa092#diff-b47f1bf1cb091c4cf74c73c060dda15e4157c34e828676587f054d7468937b02L166
The selector was part of the original blacklist so you'd have to ask @twschiller:
- https://github.com/pixiebrix/pixiebrix-extension/pull/265
The selector was part of the original blacklist so you'd have to ask @twschiller:
@jcforest while those selectors are unique, the are not reliable selectors. "Aura" is the UI framework used by Salesforce. Like emberjs, it adds attributes for which the values are valid on a single page load. We cannot generate selectors that target them, because the values may (in this case, will likely be) invalid on the next page load

Also, the aura class does not appear to be unique, e.g., see forceBrandBrand

The approach of the linked GitHub issue is to find stable anchors, e.g., .oneWorkspace.active to attach to enable automatic inference
@twschiller When do we inject pageScript?
The interesting point is the selector created from safeCssSelector function passes requreSingleElement validation here but it doesn't find the element with same selector in the pageScript. (https://github.com/pixiebrix/pixiebrix-extension/blob/dadda478584d06d2015c7bbc3d98b42da07b035b/src/nativeEditor/selector.ts#L199)
@twschiller When do we inject pageScript?
It's injected via the lifecycle file that runs when the contentScript is injected: https://github.com/pixiebrix/pixiebrix-extension/blob/e09c6e28eeaab3f1e1403b1ceb5cefd491302d7b/src/contentScript/lifecycle.ts#L54-L54
Codecov Report
Merging #4191 (2f2de86) into main (e664454) will increase coverage by
0.01%. The diff coverage is81.25%.
@@ Coverage Diff @@
## main #4191 +/- ##
==========================================
+ Coverage 48.60% 48.62% +0.01%
==========================================
Files 878 878
Lines 26159 26176 +17
Branches 5402 5404 +2
==========================================
+ Hits 12715 12728 +13
- Misses 12518 12521 +3
- Partials 926 927 +1
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/contentScript/nativeEditor/elementPicker.ts | 0.00% <0.00%> (ø) |
|
| src/pageEditor/fields/SelectorSelectorWidget.tsx | 62.50% <ø> (ø) |
|
| ...rc/contentScript/nativeEditor/selectorInference.ts | 69.09% <96.29%> (+2.20%) |
:arrow_up: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
@jcforest To recap our call, here's what we need for this PR:
- [x] Run selector generation from the content script instead of the page script when framework is not provided (to avoid the Salesforce issue with differences in selection behavior)
- [x] Define a constant SALESFORCE_SELECTOR_HINTS, with properties for the following: - Selector to determine if the site is a Salesforce lightening interface (i.e., if the heuristics should be applied), i.e., the "site rule" - Array of selector patterns to denylist, e.g., patterns including the data-aura-rendered-by attribute - Array of known good selector patterns - Array of known good stable anchors on the page
- [x] Modify the inference to take into account these site-specific rules if the site rule matches (in addition to the general rules)
- [x] In the PR demo/writeup, please include examples of selectors generated for fields/parts of the salesforce interface
After this PR, we'll then choose another strategic SaaS application, e.g., Zendesk. Once we have a set of site heuristics, we'll work toward providing these from our serve so we can keep them up-to-date
@twschiller I updated PR as we discussed.