Ihsan Rehman
Ihsan Rehman

Reputation: 87

Protractor typescript issue while checking value from select menu

enter image description hereI am automating by using protractor typescript I am facing issue while selecting specific value from select menu, please see the screenshot

<div class="pq-select-menu">
<label class="pq-select-option-label ui-state-enable" id="pq-option-565-0">
<input type="checkbox"><span class="pq-left-input">Application Administrators(1001)</span></label>
<label class="pq-select-option-label ui-state-enable pq-state-hover" id="pq-option-565-1">
<input type="checkbox"><span class="pq-left-input">Power Users(1002)</span></label>
<label class="pq-select-option-label ui-state-enable" id="pq-option-565-2">
<input type="checkbox"><span class="pq-left-input">Users(1003)</span></label>
<label class="pq-select-option-label ui-state-enable" id="pq-option-565-3">
<input type="checkbox"><span class="pq-left-input">automationGroup(1005)</span></label>
<label class="pq-select-option-label ui-state-enable" id="pq-option-565-4">
<input type="checkbox"><span class="pq-left-input">TestGroup2(1024)</span></label>
</div>

After clicking on select menu by element(by.xpath('.//td[@data-container-for="groups"]//div[@class="pq-select-text"]')).click(); enter code here How I can select and to check if that value is checked or not.

Upvotes: 0

Views: 34

Answers (1)

DublinDev
DublinDev

Reputation: 2348

You can take advantage of xpath axes. They let you easily find elements relative to one another.

In this case you would identify the span tag using the text and find the preceding input within the same label

let inputEle = element(by.xpath('//div[@class="pq-select-menu"]//span[text()="Users(1003)"]/preceding-sibling::input'))

console.log(await inputEle.isSelected()) //should return true or false

Upvotes: 1

Related Questions