How to get the text from a parent element only and not from its children - Protractor

How to get the text from a parent element only and not from its children - Protractor

Content Index :

How to get the text from a parent element only and not from its children - Protractor
Tag : angular , By : Felix Almeida
Date : November 28 2020, 04:01 AM

hop of those help? In selenium if you perform get text on parent element by default it will take all the child element text too, So when you perform by.cssContainingText it fails if you have child elements.
To avoid this

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Get parent element text without children's text

Tag : javascript , By : user183676
Date : March 29 2020, 07:55 AM
this will help I seem to be digging a deeper and deeper hole for myself, but I am determined to solve this now. , Do you not just want the text of the element?:
if ($(v).find('li').length) {
  $(v).find('> a').text();

jQuery - get only parent element text without children

Tag : javascript , By : Enrique Anaya
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , You could filter away everything that is not plain text by looping all contents:
var node = $('.someParentDiv > span').contents().filter(function() {
    return this.nodeType == 3; // text node


How to get text from parent element and exclude text from children (C# Selenium)

Tag : chash , By : arbeitandy
Date : March 29 2020, 07:55 AM
Any of those help This is a common problem in selenium since you cannot directly access text nodes - in other words, your XPath expressions and CSS selectors have to point to an actual element.
Here is the list of possible solutions for your problem:
string outerHTML = driver.FindElement(By.CssSelector(".linksSection > a#google")).GetAttribute("outerHTML");

HtmlDocument html = new HtmlDocument();

HtmlAgilityPack.HtmlNode a = html.DocumentNode.SelectNodes("//a[@id='google']");
HtmlNode text = strong.SelectSingleNode("following-sibling::text()");


Protractor does not see the element's children

Tag : javascript , By : Marc
Date : March 29 2020, 07:55 AM
this one helps. element(by.css('.form-group')) returns an ElementFinder, not the DOM element you need to query its children. This works kinda slow if you have a lot of elements but does the job:
var getLeafs = function(node) {
    return node.all(by.css('*')).filter(function(child) {
        return child.all(by.xpath('*')).count().then(function(childrenCount) {
            return childrenCount === 0;
var leafs = getLeafs(element(by.css('.form-group')));

leafs.count().then(function(c) {

How can we click on a parent element of a particular text in protractor

Tag : development , By : Rb.Ridge
Date : March 29 2020, 07:55 AM
around this issue Our UI code is given below. , Short answer
let h4ByText = (text) => element(by.xpath(`//*[@class="frx-rule-body"]//h3[contains(text(),"${text}")]//ancestor::div[contains(@class,"frx-rule-block")]//h4`));
Related Posts Related QUESTIONS :
  • Can someone help me out here, can't get the routing to work properly, keep getting 404
  • Providing/Injecting third party service to component while angular component unit testing
  • Using Reactive Forms to send value from field wrapped in compulsory object
  • how to get http response from typescript post
  • how to get public IP in Angular Project
  • Access Nested Models from function Angular
  • Angular 7 - Set the data source for the Select/dropdown box
  • Angular Material Dialogue issue - Error: The selector "dialog-result-example-dialog" did not match any element
  • BodyParser doesn't parse - but everything looks right to me. How to resolve `Cannot read property of undefined`
  • Deep Linking with IOS and Android Nativescript
  • Angular 8 + IE 11: Some polyfills are missed
  • How access form attributes from component?
  • Pass all FromGroup control values to another FormGroup
  • In Angular 7, how do I access the component that emitted an event?
  • Not able to call a method when a feature/marker is selected in OpenLayers
  • How to Implement Nested NG If else conditions in Angular 8
  • Want only single true or false value from observers
  • How to add react custom element in angular 6
  • StaticInjectorError(AppModule)[MainComponent -> MatDialog]
  • Loop through data set showing undefined
  • Why does the Angular Material table mat-paginator pagesize not work?
  • Can Web API get input from angular client for confirmation and continue execution?
  • Will the angular build include the spec file size?
  • Meta tags angular 7
  • Can't find file on stackblitz Angular project
  • AngularFire Auth exchange FireBase token for my platform's token before re-direct
  • Angular 8 Component / Service: How to retrieve data from async function in service
  • Add a control to a dynamic Angular reactive form
  • Looking to Add Role-Based Authentication System
  • Angular 7/8, 1 dependency is interfering with another one, How to avoid the loading of a deep dependency while inside a
  • Compiler errors (resolving) when compiling after addition of Firebase Admin SDK
  • wrapper observable event on top of http call
  • Nginx container does not send requests to back-end
  • ngOnInit starts before APP_INITIALIZER is done
  • How to trigger a data service call in Angular
  • Where do I declare my external service in my app.module.ts file?
  • event propagation cdk drag
  • use argument as object property in angular
  • How to create new object in redux selector and return it
  • How can I show my own text status before i switch my toggle button while using mat-slide-toggle
  • Get the API response and store the data in to an array
  • How to obtain previous and new value from Angular mat-select?
  • Send payload data with POST/PUT/PATCH requests to Sentry.io
  • Angular 8 not working in IE 11 and Safari browser
  • How to create function name from json in Angular 7
  • Im trying to push values from an array with objects to another array with objects
  • Got an error when I add "changeDetectionStrategy" to my app
  • Angular typescript object undefined at start leading to undefined error
  • Failed: Template parse errors: There is no directive with "exportAs" set to "bsDatepicker" while run
  • Error: Can't resolve all parameters for setupPlatform: (?, [object Object], [object Object])
  • Differences between ng build and ng build --watch
  • Does an angular component ever destroy when it is subscribed to router change event once?
  • How do I get the JSON response from httpModule.get?
  • Ngx-logger implementation in angular 8
  • font size increase decrease by button using angular 7
  • Are selectors and module declarations mandatory for components?
  • Why angular is adding '#' in each route?
  • how to block the subsequent clicks in angular?
  • Ionic Angular TypeError: architect_1.createBuilder is not a function
  • Angular app doesn't work on Firefox after updating it to Version 8
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com