I have something like the following markup:
<div class="test">
<div class="test2">test</div>
<div class="test2">test2</div>
<div class="test2">test3</div>
<div class="test2">test4</div>
</div
I want to click the first test2 class
I have something like the following markup:
<div class="test">
<div class="test2">test</div>
<div class="test2">test2</div>
<div class="test2">test3</div>
<div class="test2">test4</div>
</div
I want to click the first test2 class
Samuel
On
Check this cheatsheet, it explains how to get the first element of an html tag : https://devhints.io/xpath
$I->click('(//div[@class="test2"])[1]');
This code should work, just try it here : https://extendsclass.com/xpath-tester.html
Copyright © 2021 Jogjafile Inc.
Maybe something like this .test .test2:nth-child(1)