My task involves working with a WebElement and my goal is to extract the CSS selector string from it. During code debugging, I found this value stored in a variable:
[[ChromeDriver: chrome on MAC (345345345n5435345b34)] -> css selector: div[class='alert alert-danger']]
What I actually require is just the css selector string:
div[class='alert alert-danger']]
I am aware that I can split the string, but I am curious if there is a more efficient method provided by Selenium for achieving this. I have already tried using .getAttribute("class")
, which gives me "alert alert-danger" but not the entire selector.
Thanks for taking the time to read this. Any assistance or suggestions would be highly appreciated.