I am a Software Quality Assurance Engineer and I am trying to create an Automated test for a webpage.
Some background:
The framework of Selenium that my company uses ONLY allows you to use X paths saved as an object then you use pre-existing methods like "click (someobject)" or "enter (someobject)" etc.
Problem:
I'm currently trying to create a test that selects multiple buttons that are on the same class. There are 6 set buttons that I need to be able to select. Now I can do this but using:
`//*[@id="tenant-details-accordion"]/div[1]/div[2]/div/div[2]/div[1]/div/a
//*[@id="tenant-details-accordion"]/div[1]/div[2]/div/div[2]/div[2]/div/a
//*[@id="tenant-details-accordion"]/div[1]/div[2]/div/div[2]/div[3]/div/a
//*[@id="tenant-details-accordion"]/div[1]/div[2]/div/div[2]/div[4]/div/a
//*[@id="tenant-details-accordion"]/div[1]/div[2]/div/div[2]/div[5]/div/a
//*[@id="tenant-details-accordion"]/div[1]/div[2]/div/div[2]/div[6]/div/a`
-However this is only temporary because the test will fail later down the road when a button is removed... I have talked to the Development team about adding Unique ID's to each button. But it does not seem like that is a path they want to go down...
Possible Solution:
Is it possible to narrow the ‘scope’ of Selenium?
For example telling Selenium to look through a specific class instead of the entire page?
-My thought is to have it search for a class, match a specific text, then select Set.If yes, then also is it possible to combining multiple X path's Something like....
//div[@class='col-sm-4'].... //div[contains(.,'Birth Date: Set +')]
My thought is that I could create an Xpath that narrows what Selenium will actually be looking through.
Searching for the class
Searching for Text "Birth Date"
Selecting Set Button
You would want something like this:
Meaning select the link from the
div
that has aclass
with valuecol-sm-4
and contains the specified text.Or it could also work like this: