css selector for dynamic MuiButton-label

css selector for dynamic MuiButton-label

Problem Description:

I am trying to find a selector for this date element, it is found as MuiButton-label but the date text is dynamic, I can locate using the xpath in the playwright code but looking for a way to locate it using a css selector. Appreciate your time and help.

enter image description here

with .MuiButton-label class selector it narrows down to 4 elements, however the text cannot be sued to pinpoint to date as it would change I am looking for a way other than regex :
enter image description here

Solution – 1

Try this selector:

.MuiButton-label span:nth-child(2)

Explanation of selector:

  • .MuiButton-label: An element with class "MuiButton-label"
  • span: Sub elements of previous element with tag "span"
  • :nth-child(2): We will get 2 span, so we get the second one

Solution – 2

could locate the element with this selector

button >> nth=3>>span>span:nth-child(2)
Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.