You need to sign in to do that
Don't have an account?
Jacob Friedman 11
Test Automation Strategies in Lightning due to dynamic locators
All,
I'm working on Selenium Test Automation of my App using the LEX. In Classic, locators are static in that I can reference an ID number or name, whereas it seems the same field/object in LEX has dynamic IDs depending on when I access said element.
HTML from LEX yields:
I try to use the bold faced section as a locator, but it changes each time I click on it. Here's another example of the same elment. As you can see the id is now 90, instead of 60 above.
Here's a snippet from classic, where I can always US the same ID. It never changes. Has anyone found a solution to this problem for finding element locators in LEX?
I'm working on Selenium Test Automation of my App using the LEX. In Classic, locators are static in that I can reference an ID number or name, whereas it seems the same field/object in LEX has dynamic IDs depending on when I access said element.
HTML from LEX yields:
<a aria-required="true" class="select" aria-disabled="false" aria-haspopup="true" tabindex="0" role="button" aria-label="Enrollment Type" title="" href="javascript:void(0);" data-aura-rendered-by="2944:0" data-interactive-lib-uid="60">--None--</a>
I try to use the bold faced section as a locator, but it changes each time I click on it. Here's another example of the same elment. As you can see the id is now 90, instead of 60 above.
<a aria-required="true" class="select" aria-disabled="false" aria-haspopup="true" tabindex="0" role="button" aria-label="Enrollment Type" title="" href="javascript:void(0);" data-aura-rendered-by="4995:0" data-interactive-lib-uid="90">--None--</a>
Here's a snippet from classic, where I can always US the same ID. It never changes. Has anyone found a solution to this problem for finding element locators in LEX?
<select id="00No000000DyWd7" name="00No000000DyWd7" tabindex="8"><option value="">--None--</option><option value="New Enrollment">New Enrollment</option><option value="Re-Enrollmet">Re-Enrollmet</option><option value="Re-Validation">Re-Validation</option><option value="Information Update">Information Update</option></select>
For instance, I have a custom object called 'Credentialing'. The word 'Credentialing' is used a lot throughout my app, so it's hard to key in on this. What I was looking to do was locate a lookup field called 'Credentialing Manager', which looks up to Salesforce Users. I used the below locators to Edit the desired field, type values to search for users, and select the users.
2. Type in the clicked on field: xpath="//input[@placeholder='Search People']"
3. Select name from list that was displayed based on #2: xpath="input[@placeholder='Search People']//following::li[3]" This finds the field placeholder "Search People" and then navigated to the third li tag that folows it.
A less brittle way of finding #3 above is to use the following xpath because it's not relying on the 3rd li tag, but looking for specific text you're searching for. For instance I was searching for my name, Jacob Friedman, in #2 above. This way, I can use the same locator across many orgs and get consistent results. If I use the li locator, the location of value that I am looking for could vary in every single org, thus making my test less versatile.
xpath="//div[@title='Jacob Friedman']"
Please find my element below,
<a aria-required="false" class="select" aria-disabled="false" aria-describedby="1838:2908;a-label" aria-haspopup="true" tabindex="0" role="button" title="" href="javascript:void(0);" data-aura-rendered-by="1848:2908;a" data-interactive-lib-uid="75">--None--</a>
i am testing a lightning component with selenium below is the given image
its a tab on Account which is showing its related child records of custom object. the css is given below:-
<span class="title" data-aura-rendered-by="1284:0">Family Records</span>
i tried script with xpath and css for it as below:-// WebElement Family = driver.findElement(By.xpath("(// *[@class=\"title\"])[3]"));
WebElement Family = driver.findElement(By.cssSelector(".tablist, .tabs__nav, .tabs__item active, .uiTabItem"));
Family.click();
did not worked for me .can you tell me what i am missing?
Any suggestions?