mardi 4 décembre 2018

xpath - select element that contains text in CLASS name

I am trying to find a way to select this particular web element:

<snack-bar-container class="mat-snack-bar-container ng-tns-c43-25 ng-trigger ng-trigger-state snackbar-info mat-snack-bar-center ng-star-inserted" role="alert" style="transform: translateY(0%);"><!----><simple-snack-bar class="mat-simple-snackbar ng-tns-c44-26 ng-trigger ng-trigger-contentFade ng-star-inserted" style="">Asset successfully loaded! <!----><button class="mat-simple-snackbar-action ng-tns-c44-26 ng-star-inserted" style="">Close</button></simple-snack-bar></snack-bar-container>

Currently I was selecting that by text:

.//snack-bar-container//*[contains(text(),'There are errors on the page:')]

But because there will be localisation (translation of texts) it will be unreliable in a long term, question is, is how to select element, which has a class attribute that contains some specific text in class name.

As you can see my web element class is very long, and often varies, so I need to check if it contains some specific text, I tried with:

.//[contains(@class,’snackbar-info’)]

But it does not work, any suggestions? Thank you.

Aucun commentaire:

Enregistrer un commentaire