Pavel
Pavel

Reputation: 11

TestCafe: How to select the first DOM item with a certain class pattern?

I need to select the first div element whose classes match the style-[0-9]+ classB pattern.

e.g.:

<div class="style-123 classB">Div1</div>
<div class="style-235 classB">Div2</div>
<div class="style-173 classB">Div3</div>

The Div1 div should be selected in this example.

How to do that in TestCafe?

Upvotes: 1

Views: 216

Answers (1)

Rajesh Kathiriya
Rajesh Kathiriya

Reputation: 172

Selector('div').withAttribute('class', /style-[0-9]+ classB/)

Upvotes: 2

Related Questions