'How can i get dynamic element from website so I can use it on a nightwatch

I want to get "Cancel" element. But the element of Cancel Button is dynamic, like this : enter image description here

//*[@id="TD/D0202/22/00321-content"]/div/button[1]/span

How can i use the element to my nightwatch script?



Solution 1:[1]

CSS Selector:

span[class = "MuiButton-label"]
button[class*= "MuiButtonBase"] span[class = "MuiButton-label"]

XPATH Selector:

//span[@class = "MuiButton-label"]
//span[@class = "MuiButton-label" and contains(text(), "Cancel")]
//button[contains(@class, "MuiButtonBase")]/span

There are a lot of possibilities to capture this element.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vladislav Bulanov