I am trying to access the input element of the last child in this code snippet. Specifically, I want to retrieve the text Text Reply - Delete
.
<div class="priority-intent-div">
<div class="row add-priority-intent-div">
<div class="col-xs-12">
<input type="hidden" name="priorityIntentId" value="5f8fb2f031f8a20a0cd6e2d1">
<div class="form-group">
<div class="intent-conditions">
<button onclick="addIntentCondition(this)" type="button" class="btn btn-default" style="width: 100%">
<span class="fa fa-plus"></span> Add Condition</button>
</div>
<label for="priorityIntentName" class="control-label">Intent Name</label>
<input type="text" name="priorityIntentName" placeholder="Greeting" single="" maxlength="20" class="form-control maxlengthBadge" value="Text Reply - Delete" required="">
<div class="help-block with-errors"></div>
I attempt to target the last child using this code:
let block = await driver.findElement(By.css('div.priority-list-tab > div.priority-intent-list > div:last-child'))
await driver.executeScript("arguments[0].scrollIntoView(true)", block)
While it successfully scrolls down to the last child with the class priority-intent-div
, there seems to be an issue when trying to extract the text from that last child (specifically from the input tag) using:
priority_intent_name = await block.findElement(By.xpath('div/div[1]/div/input'))
priority_intent_value = await priority_intent_name.getAttribute('value')
expect(priority_intent_value).to.be.eq(intent_name)
Instead of retrieving the desired value from the last child, it is returning the value of the first child. Can anyone offer assistance? https://i.sstatic.net/rBu72.png