Reputation: 3
I am having trouble writing the exact location of the second div.row element based on the child element preceding it (which is the second div.trigger element in the page)
<div id='subscription'></div>
<div class='settings'></div>
<div class='generic'></div>
<div class='trigger'></div>
<div class='row'></div>
<div class='trigger'></div>
<div class='row'></div>
The reason for this is that, upon loading a page, no trigger elements initially appear. But when I click on a checkbox, one trigger appears, and so on since there are at least 3 checkboxes in the page.
Sorry for the noobness of this question, but i haven't found a solution yet and i'm hopelessly stuck. Any help will be appreciated. Thanks!
Upvotes: 0
Views: 909
Reputation: 13
Try xpath-expression
like below which should work:
By.xpath("//div[@class='settings']/child::div[position()=2][attribute::class='row']");
(or)
By.xpath("//div[@class='settings']/following-sibling::chapter[position()=1]");
Upvotes: 0
Reputation: 5419
Take all div with class 'row' and than take 2-nd one
//div[@class='row'][2]
Upvotes: 2