You need to sign in to do that
Don't have an account?
Imran Chowdhry
Why is Selenium/JS/JQuery unable to locate elements in Winter 2020 release of Salesforce?
Hello,
I have built an automation tool to help with regression testing, and so far it works without any issues in the Summer 19' release. I had a sandbox reserved to test the automation tool in the Winter 2020 release, and I am unable to locate multi-select picklists and custom forums under related lists in the Winter 2020 preview of Salesforce.
I have used Selenium functions to locate elements, JavaScript, and JQuery, all which work on the Summer 19 release but not the Winter 2020 release.
AAs you can see, I am able to locate the same value in the multi-select picklist with no issues..
I am unable to locate the elements that I was able to locate in Summer 2019
Does anyone have any idea why this may be happening?
I have built an automation tool to help with regression testing, and so far it works without any issues in the Summer 19' release. I had a sandbox reserved to test the automation tool in the Winter 2020 release, and I am unable to locate multi-select picklists and custom forums under related lists in the Winter 2020 preview of Salesforce.
I have used Selenium functions to locate elements, JavaScript, and JQuery, all which work on the Summer 19 release but not the Winter 2020 release.
AAs you can see, I am able to locate the same value in the multi-select picklist with no issues..
I am unable to locate the elements that I was able to locate in Summer 2019
Does anyone have any idea why this may be happening?
DOM API Changes
Shadow DOM is a standard that encapsulates the internal document object model (DOM) structure of a web component. The internal DOM structure is called the shadow tree. In Winter ’20, code can’t use document or document.body to access the shadow tree of a Lightning web component.
Per the Shadow DOM specification, elements in a shadow tree aren’t accessible via traditional DOM querying methods. To access its own shadow tree, a Lightning web component uses this.template.querySelector().
For example, code in a test can’t call document.querySelector() to select nodes in a Lightning web component’s shadow tree.
http://salesforcecodex.com/2019/08/salesforce-winter-20-release-feature-enhancements-for-development/
All Answers
DOM API Changes
Shadow DOM is a standard that encapsulates the internal document object model (DOM) structure of a web component. The internal DOM structure is called the shadow tree. In Winter ’20, code can’t use document or document.body to access the shadow tree of a Lightning web component.
Per the Shadow DOM specification, elements in a shadow tree aren’t accessible via traditional DOM querying methods. To access its own shadow tree, a Lightning web component uses this.template.querySelector().
For example, code in a test can’t call document.querySelector() to select nodes in a Lightning web component’s shadow tree.
http://salesforcecodex.com/2019/08/salesforce-winter-20-release-feature-enhancements-for-development/
"To access its own shadow tree": strong constraint.
Working with Shadow DOM Elements using Webdriver
https://www.seleniumeasy.com/selenium-tutorials/accessing-shadow-dom-elements-with-webdriver
If you look at the DOM structure, every element that has ShadowDOM also has a shadowRoot property which describes the underlying elements.
... but it is very restricted even if you get the shadowRoot property.