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
• 9,030 points
621 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

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

.//*[@name='BookType']/ancestor::label
answered Mar 26, 2018 by nsv999
• 5,030 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
2,502 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
206 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
• 12,030 points
7,380 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,030 points
51 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
409 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
40 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,030 points
63 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,100 points
4,396 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.