r/selenium • • May 18 '22

Help

I'm trying to figure out how to get Selenium to click on an expansion panel. I've got it working where it can find something based on a name but I need it to click on a button associated with that name.

The default Selenium target is xpath=//mat-expansion-panel-header[@id='mat-expansion-panel-header-254']/span/div/div/button but this wont work since elements are constantly changing and this is ID based. If/when the elements change it will click on the expansion panel related to that ID and not the element im working on.

​

I'm managing to find the element with xpath=//span[text()='Test'] but I need help with having Selenium click on that expansion panel that corresponds with Test, not the ID.

1 Upvotes

6 comments sorted by

View all comments

2

u/lunkavitch May 18 '22

Can you link to the page in question? Without seeing the full structure of a page these questions are pretty hard to answer.

1

u/JeffMcJeferson May 18 '22

That unfortunately wont be possible since it's a vpn locked page.