按包含指定值的 HTML 属性选择元素

要通过包含指定值的 HTML 属性选择元素,请使用 css 定位器模式 [attribute * = value]

//selects the first element with href value that contains'cont'
element(by.css('[href*="cont"]')); 

//selects the first element with tag h1 and class attribute that contains 'fo'
element(by.css('h1[class*="fo"]')); 

//selects all li elements with a title attribute that contains 'users'
element.all(by.css('li[title*='users']'));