Skip to main content
improved title and tagging.
Source Link
kjhughes
  • 112.7k
  • 31
  • 198
  • 276

How XPath to locate an element using "and" operator with multiple containscontaining text functionsnodes?

I'm trying to locate the content from <div class="initiative-section__content">...</div> by using this XPath "//*[contains(text(),'Created')]/following-sibling::*", but it's returning two elements since there is also Created Date"Created Date". And I can't figure out how to add "By" to XPath. I tried something like this but it didn't work "//*[contains(text(),'Created') and contains(text(),'By')]/following-sibling::*"

Any ideas?

<div class="initiative-section__title"> "Created" " By" </div> <div class="initiative-section__content">...</div> 

How to locate an element using "and" operator with multiple contains text functions

I'm trying to locate the content from <div class="initiative-section__content">...</div> by using this XPath "//*[contains(text(),'Created')]/following-sibling::*", but it's returning two elements since there is also Created Date. And I can't figure out how to add "By" to XPath. I tried something like this but it didn't work "//*[contains(text(),'Created') and contains(text(),'By')]/following-sibling::*"

Any ideas?

<div class="initiative-section__title"> "Created" " By" </div> <div class="initiative-section__content">...</div> 

XPath to locate an element containing text nodes?

I'm trying to locate the content from <div class="initiative-section__content">...</div> by using this XPath "//*[contains(text(),'Created')]/following-sibling::*", but it's returning two elements since there is also "Created Date". And I can't figure out how to add "By" to XPath. I tried something like this but it didn't work "//*[contains(text(),'Created') and contains(text(),'By')]/following-sibling::*"

Any ideas?

<div class="initiative-section__title"> "Created" " By" </div> <div class="initiative-section__content">...</div> 
Source Link
Alex
  • 35
  • 5

How to locate an element using "and" operator with multiple contains text functions

I'm trying to locate the content from <div class="initiative-section__content">...</div> by using this XPath "//*[contains(text(),'Created')]/following-sibling::*", but it's returning two elements since there is also Created Date. And I can't figure out how to add "By" to XPath. I tried something like this but it didn't work "//*[contains(text(),'Created') and contains(text(),'By')]/following-sibling::*"

Any ideas?

<div class="initiative-section__title"> "Created" " By" </div> <div class="initiative-section__content">...</div>