Finding parent element in Protractor

0 votes
<label class="radio inline check">

            <input class="input ng-new ng-valid" name="BookType" required="" type="radio">

            <!---->

            <!---->
            Fiction
</label>

<label class="radio inline check">   

            <input class="input ng-new ng-valid" name="BookType" required="" type="radio">

            <!---->

            <!---->
            NonFiction
</label>

<label class="radio inline check">

            <input class="input ng-new ng-valid" name="BookTypeReal" required="" type="radio">

            <!---->

            <!---->
            Fiction
</label>

<label class="radio inline check">   

            <input class="input ng-new ng-valid" name="BookTypeReal" required="" type="radio">

            <!---->

            <!---->
            Fantasy
</label>

If I use

element.all(locator).filter(filterFn

the text returned is empty.

How can I go to parent element <label> to get the text?

label[class="radio inline check"] 

returns 60 elements where more than one getText will return same text so it won't be unique.

input[name="BookType"] 

returns two elements where each element is unique.

Mar 26, 2018 in Selenium by nitinrawat895
• 10,070 points
774 views

1 answer to this question.

0 votes

To get the parent element, you can use XPath's ancestor:

.//*[@name='BookType']/ancestor::label
answered Mar 26, 2018 by nsv999
• 5,050 points

Related Questions In Selenium

0 votes
1 answer

(Protractor) Finding specific row in ng-table by text

Try this Return the filtered elements before trying ...READ MORE

answered May 10, 2018 in Selenium by Samarpit
• 5,130 points
3,261 views
0 votes
1 answer

Protractor waiting for element to be in DOM

You should be able to use browser.wait together with ...READ MORE

answered Sep 17, 2018 in Selenium by Meci Matt
• 9,400 points
391 views
0 votes
1 answer

How to use JavaScript in selenium to click an Element?

Executing a click via JavaScript has some ...READ MORE

answered Apr 13, 2018 in Selenium by Shubham
• 13,110 points
9,787 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
258 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
626 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
253 views
0 votes
1 answer

Finding an element in Selenium

Basically, they are not too different. The ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,050 points
90 views
0 votes
2 answers

Unable to Click on an Element in Selenium (Python) even after finding it.

Here, I give you working script which ...READ MORE

answered Sep 19, 2018 in Selenium by Priyaj
• 56,160 points
5,935 views