I want to check if my checkbox is unchecked, the only parameter that changes is aria-label.
Is it possible to check that parameter with javascript on Sélenium ?
<svg focusable="false" viewBox="0 0 24 24" aria-hidden="true" role="img" aria-label="CheckBoxOutlineBlankIcon"><path d="M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"></path></svg>
Thanks in advance.
CodePudding user response:
CodePudding user response:
To validate if the checkbox is checked/unchecked you can extract the value of the aria-label
attribute to probe further as follows:
Using css:
console.log(await driver.findElement(By.css("svg.1-MuiSvgIcon-root-778")).getAttribute('aria-label'));
Using xpath:
console.log(await driver.findElement(By.xpath("//*[name()='svg' and contains(@class, '1-MuiSvgIcon-root-778')]")).getAttribute('aria-label'));
CodePudding user response:
Thank you all
Thanks to your help, I manage to find my aria-label parameter. Since the await and console.log don't work for me (invalid), I modify a bit and now it works !
Here what I do:
var test = driver.findElement(By.xpath("//*[name()='svg' and contains(@class, '1-MuiSvgIcon-root-778 1-makeStyles-root-875')]")).getAttribute("aria-label");
System.out.println(test);
Result => CheckBoxOutlineBlankIcon
Thanks again !