简体   繁体   中英

i want to inspect span class element using Selenium using other Selenium attributes than Xpath

Please enter your password

i want to get the message "Please enter your password"

Is there any other attribute than Xpath?

The code appears like this:

<span class="k-widget k-tooltip k-tooltip-validation k-invalid-msg" data-for="password" role="alert"><span class="k-icon k-warning"> </span> Please enter your password</span>

Thanks

Try below code:-

String d =driver.findElement(By.cssSelector("span[data-for=password]")).getText();
System.out.println(d);

Hope it will help you :)

can u try folloiwng one: WebElement ele= driver.findElement(By.className("k-widget k-tooltip k-tooltip-validation k-invalid-msg")); String text=ele.getText(); System.out.println(text); Try it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM