[Feature] Add possibility of creating Locators with variables
See original GitHub issueHi, it would be more convenient to create Locators with the possibility of specifying variable values exactly before executing some actions. For example I have two elements on the page:
await this.page.click('.header-actions [helptag="default-filters"]:not(.mat-button-disabled)');
await this.page.click('.header-actions [helptag="apply-filters"]:not(.mat-button-disabled)');
As we can see, only helptag
differs.
With the current implementation of Locators I need to create 2 locator elements or make my own functions to generate raw string selector and pass it to locator.
I propose creating out-of-the box implementation in Locators for such functionality.
Maybe something like this:
headerActionBtns = this.page.locator('.header-actions [helptag="${btnName}"]:not(.mat-button-disabled)', btnName)
headerActionBtns.click({btnName: 'default-filters'});
or
headerActionBtns.with({btnName: 'default-filters'}).click();
Please consider. Thank you
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Locators In Selenium WebDriver With Examples - LambdaTest
This blog deep dives into the multiple locators in Selenium WebDriver and demonstrates the usage of those locators while performing Selenium ...
Read more >How to pass a variable to the selector and the python function ...
In the locators file, I write my selector, which contains a variable. I need it to be variable because later on I will...
Read more >Locators and Variables
Variables represent text strings to be replaced at the time of the execution of a test case. We have predefined variables ready to...
Read more >How to use locators with parameters
use a locator for each page element; use a method that creates the locator for each page locator; use a locator pattern with...
Read more >Page Object Model (POM) In Selenium With Examples || Toolsqa
Additionally, if there is a change in such a locator, you will have to go through the entire code to make the necessary...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
+1 for this. I ran into many situation where multiple locators are pretty much the same, except for their text. So it would be great to use the same locator for all those elements and just have a variable for the text value.
+1, this feature will be awesome for the community.