jeudi 31 janvier 2019

How to find classname (in selenium java) starting with a particular text and ending with a particular text?

Below is the element and I need to find the class names matching with the first "css-" and ending with "widget", How do i find it in selenium (java)?

tried with the below code, but it didnt work

List<WebElement> list1 = driver.findElements(By.xpath("//body[starts-with(@class, 'css-')]"));
List<WebElement> list2 = driver.findElements(By.xpath("//body[contains(@class, 'css-')]"));
List<WebElement> list3 = driver.findElements(By.xpath("//body[ends-with(@class, 'widget')]"));

Aucun commentaire:

Enregistrer un commentaire