XPath Operators & XPath Functions - and, or, text, contains, starts-with, normalize-space

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 เม.ย. 2020
  • In this video, I have explained XPath operators and XPath functions - and, or, text, contains, starts-with, normalize-space.
    XPath (XML Path Language) is a query language for selecting nodes from an XML document.
    Or in other words, XPath is a query language for finding elements in an HTML web page.
    ------ XPath Operators ------
    = Tests whether two expressions are equal.
    < Tests whether the first expression is less than the second.
    <= Tests whether the first expression is less than or equal to the second.
    > Tests whether the first expression is greater than the second.
    >= Tests whether the first expression is greater than or equal to the second.
    != Tests whether the two expressions are not equal.
    and - Tests whether both the first and second expressions are true. If the first expression is false, the second is not evaluated.
    or - Tests whether either the first or second expressions are true. If the first expression is true, the second is not evaluated
    ------ XPath Functions ------
    text() - Selects the text nodes of the current context node.
    Contains() - Contains method is used when we know about the partial attribute value or partial text associated with the web element.
    Starts-with() - starts-with method is used when we know about the initial partial attribute value or initial partial text associated with the web element.
    normalize-space() - The normalize-space function ignores the leading, trailing, and repeating white spaces, that means after applying the normalize-space the text become normalized with no line breaks, and give a proper sentence.
    ------ Examples ------
    //td[text()=5000]
    //button[@id='refreshBtn' and @value='Refresh']
    //button[@id='refreshBtn' or @value='Refresh']
    //a[text()='Sign in']
    //a[contains(text(),'Sign')]
    //button[contains(@class,'sign')]
    //div[starts-with(@class,'container')]
    //label[normalize-space(text())='First Name']
    ▶️ Next Video Link: • XPath Axes - ancestor,...
    ◀️ Previous Video Link: • What is XPath? Types o...
    ↔️ XPath (XML Path Language) Playlist Link: bit.ly/2RlLdkw
    ✴ Checkout my other playlists: bit.ly/3gLIAVL
    ☕ Buy me a coffee: bit.ly/33ljBWc
    👑 Join my youtube channel to get access to perks:👇
    / @hyrtutorials
    ==============================================
    ==============================================
    Connect us @
    🔗 Website - www.hyrtutorials.com
    🔗 Telegram - t.me/hyrtutorials
    🔗 Facebook - / hyrtutorials
    🔗 LinkedIn - / hyrtutorials
    🔗 Twitter - / hyrtutorials
    🔗 Instagram - / hyrtutorials
    ==============================================
    ==============================================
    🙏 Please Subscribe🔔 to start learning for FREE now, Also help your friends in learning the best by suggesting this channel.
    #xpath #functions #operators #xpathFunctions #xpathOperators #and #or #text #contains #starts-with #normalize-space #hyrtutorials #webAutomation
    how to write xpath using and,selenium interview questions,xpath examples,xpath tutorial,selenium xpath examples,how to write xpath,xpath in selenium
    hyr,selenium tutorial,selenium tutorial for beginners,selenium training,selenium testing tutorial,automation testing tools,software testing tools,selenium webdriver training,html controls,selenium webdriver,Absolute XPath,root element,tagname,attribute,attribute value,web automation,selenium xpath,xpath tutorial,dynamic xpath,selenium automation,selenium xpath java,selenium xpath tutorial,dynamic xpath in selenium webdriver,dynamic xpath in selenium using different approaches,xpath contains,xpath text,xpath,xpath tutorial selenium,how to write xpath in selenium webdriver,xpath in selenium,xpath tutorials,relative xpath,selenium dynamic xpath,xpath examples,absolute xpath and relative xpath,xpath expression,xpath in selenium webdriver,xpath tutorial for beginners,webdriver xpath
    hyr tutorials,h y r tutorials,xpath functions,xpath functions in selenium,xpath functions in xml,xpath functions example,xpath starts with and ends with,xpath normalize-space,xpath and or,xpath functions tutorial,xpath functions in selenium java,xpath text function,selenium xpath functions,xpath functions with example,types of xpath,xpath starts-with,xpath function,xpath multiple attributes,XPath Operators,XPath Operators & XPath Functions,xpath,webdriver, xpath normalize space
    yadagiri reddy, yadagiri reddy h, h yadagiri reddy, h y reddy

ความคิดเห็น • 84

  • @HYRTutorials
    @HYRTutorials  4 ปีที่แล้ว +3

    ↔️ XPath (XML Path Language) Playlist Link: bit.ly/2RlLdkw
    ✴ Checkout my other playlists: bit.ly/3gLIAVL
    ☕ Buy me a coffee: bit.ly/33ljBWc

  • @muhammadzia9421
    @muhammadzia9421 3 ปีที่แล้ว +2

    great work. both of ur tutorials css selector and this one on xpath are simply the best for the one understanding the basics. keep up the good work. appreciable.

  • @VaraLakshmiVempatapu
    @VaraLakshmiVempatapu 3 ปีที่แล้ว +1

    Your tutorials are very helpful in getting the XPath concepts. Thank you

  • @SingaporeChinnodu
    @SingaporeChinnodu 3 ปีที่แล้ว +1

    clear and precise. This is what everyone wants.

  • @kamaleshpramanik7645
    @kamaleshpramanik7645 3 ปีที่แล้ว +1

    Thank you very much for clearing many doubts.

  • @9966056933
    @9966056933 3 ปีที่แล้ว +1

    Your explanation is a way better than any others. Thanks and keep making such a good videos.

  • @angaraki
    @angaraki 3 ปีที่แล้ว +1

    Great coaching!!Thanks,

  • @minalwalke6128
    @minalwalke6128 3 ปีที่แล้ว +2

    Thank you so much sir for explaining imp things related to xpath in such simple manner.
    🙏

  • @pratapadhikari7700
    @pratapadhikari7700 3 ปีที่แล้ว +1

    Thanks for the awesome tutorial video.

    • @HYRTutorials
      @HYRTutorials  3 ปีที่แล้ว

      Thankyou, keep watching 😊

  • @vivekvineet3516
    @vivekvineet3516 ปีที่แล้ว +1

    This is the one I was looking for the best explanations.... Thank you very much

    • @HYRTutorials
      @HYRTutorials  11 หลายเดือนก่อน +1

      Thanks buddy 😊

  • @nareshgajula
    @nareshgajula ปีที่แล้ว +1

    Very good explanation. Easy to understand. Thank you

  • @mohdshahrukh5164
    @mohdshahrukh5164 2 ปีที่แล้ว +1

    One of the best video on YT regarding XPath,Thnk u sir for making such a amazing vdios

  • @yuvamani3041
    @yuvamani3041 2 ปีที่แล้ว

    hereafter, i can't able to forget this concept ... Thanks:)

  • @Solution4uTx
    @Solution4uTx 3 ปีที่แล้ว +1

    I am a beginner and your explanation made it so easy for me.

  • @FahimRahman1
    @FahimRahman1 3 ปีที่แล้ว +1

    Nice explanation. Thanks.

  • @alabioluwasegun3250
    @alabioluwasegun3250 ปีที่แล้ว +1

    Awesome. Best XPath video ever..

  • @slakshmiics
    @slakshmiics 2 ปีที่แล้ว

    Thank you so much for sharing this

  • @jamadagnithandrangi6715
    @jamadagnithandrangi6715 ปีที่แล้ว +1

    Good Explanation Brother .It's Easy to understand the concepts.

  • @mohanramakrishnakonijety9405
    @mohanramakrishnakonijety9405 11 วันที่ผ่านมา

    Thank you

  • @thetruth5672
    @thetruth5672 2 หลายเดือนก่อน

    Thanks sir

  • @tgrakesh8gmail
    @tgrakesh8gmail 4 ปีที่แล้ว +1

    Good and clear explanation👌...it will be good if u make videos on CSS selectors also..thanks.👍

    • @HYRTutorials
      @HYRTutorials  4 ปีที่แล้ว

      Yeah sure

    • @HYRTutorials
      @HYRTutorials  3 ปีที่แล้ว

      CSS Selectors videos playlist:👇
      🔗 bit.ly/2Rn0IbD

  • @swapnabhaskaruni
    @swapnabhaskaruni 2 ปีที่แล้ว +1

    when we use a attribute with normalize-space( ) do we still use @ like //tag[ normalize-space(@attribute)='value')

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      Not required for text but for any other attribute it is required

  • @sykesybwoy
    @sykesybwoy 3 ปีที่แล้ว +1

    Hey, nice vid... Is it possible to find a variable child element of an element found with a relative xpath? i.e. th[text()='xxxx'] give the the text of it's td?

    • @HYRTutorials
      @HYRTutorials  3 ปีที่แล้ว

      The question is bit confusing, can you ask it clearly?

    • @sykesybwoy
      @sykesybwoy 3 ปีที่แล้ว +1

      @@HYRTutorials I thought the question was pretty clear, it’s fine I’ve found the answer now. //th[text()=‘xxxx’]/following::td[1]

    • @HYRTutorials
      @HYRTutorials  3 ปีที่แล้ว +1

      @@sykesybwoy ohh cool

  • @joshibhushan1
    @joshibhushan1 2 ปีที่แล้ว +1

    One query here is, when you have used //td[text()=5000] , you have not applied any ' or ' ' or " " for the text and still getting the correct value , how is this happening ? I tried to do it this on the Amazon site for highlighting the products which have price more than 30000 but this is not working(of course xpath pattern was different) but if you can shed some light on that then it would be helpful

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      Yeah sure, send me the details and screenshots on hyadagirireddytutorials@gmail.com

  • @nandinirayavarapu1917
    @nandinirayavarapu1917 2 ปีที่แล้ว +1

    Sir is it correct that while using only contains method we need not to give text()? But for starts-with(), normalize-space() methods we must use text()?

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว +1

      Text function can be used with all those functions

    • @nandinirayavarapu1917
      @nandinirayavarapu1917 2 ปีที่แล้ว +1

      Ok tq sir my doubt was cleared

  • @vidyatilak
    @vidyatilak 3 ปีที่แล้ว +1

    hi could you plz post , how to write xpath ,if text is not included in any tag. "Service type"

    • @HYRTutorials
      @HYRTutorials  3 ปีที่แล้ว

      Try any of the following XPath:
      //div/following-sibling::text()
      //div/following-sibling::text()[. = "Service type"]
      //div[@class='mat-list']/following-sibling::text()
      //div[@class='mat-list']/following-sibling::text()[. = "Service type"]

  • @floraartworks
    @floraartworks 2 ปีที่แล้ว +1

    Sir , how to use sum operator in xpath to sum two consecutive td of a tr? Please give syntax

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      I dont think we can do that using xpath

    • @floraartworks
      @floraartworks 2 ปีที่แล้ว +1

      @@HYRTutorials sir in this case how to do that? Actually I am scraping website data into Excel using selenium, but don't want to use the Excel's ability to do the sum. Is there any way to sum two td of a tr during webscraping using selenium?

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      Never tried that buddy

  • @gbmohankumar9584
    @gbmohankumar9584 3 ปีที่แล้ว +1

    How to handle customized drop down ?
    Can you upload one video on that please

    • @HYRTutorials
      @HYRTutorials  3 ปีที่แล้ว

      Watch this video:
      th-cam.com/video/jBVtlGTOWu0/w-d-xo.html

  • @poojasardaana1570
    @poojasardaana1570 3 ปีที่แล้ว +1

    How can I use Suffix with Text()?

    • @HYRTutorials
      @HYRTutorials  3 ปีที่แล้ว

      U mean starting text or partial text?

  • @testtesting1137
    @testtesting1137 3 ปีที่แล้ว +1

    Thank you sir very helpful. Sir, today i got to know about a smart editor SelectorsHub for xpath, you might like to try that sir. I found that very helpful in learning and time saving with error message feature and attribute suggestion.

    • @HYRTutorials
      @HYRTutorials  3 ปีที่แล้ว

      That's good.
      But without having proper knowledge on xpath, one should not start using any add-on.
      Add-on saves your time but there are lot many cases in which you can't use the add-on.
      So it is always advisable to learn about xpath first, then for reducing the time in writing xpath you can use the add-on.

    • @testtesting1137
      @testtesting1137 3 ปีที่แล้ว +1

      @@HYRTutorials Agreed without having proper knowledge we should not use any tool not just xpath tool but i always found people say this blindly just for xpath tool. While on the other hand we are always using an xpath tool that is devtools

    • @HYRTutorials
      @HYRTutorials  3 ปีที่แล้ว

      Yes, we are already using the dev tools.
      Dev tools can be used in two ways
      1. Write your own xpath and check whether it is working or not
      2. Copy the auto generated xpath provided by dev tools.
      I encourage using option 1.
      Option 2 is again like a add-on kind of tool only.

    • @testtesting1137
      @testtesting1137 3 ปีที่แล้ว +1

      @@HYRTutorials i started using this tool SelectorsHub as Naveenautomationlabs recommends that. For option1 which you said, devtools doesn't tell whats wrong in my xpath, devtools doesn't support shadow dom, have to copy attribute values and have to inspect element again and again. Devtools also match as string because of which it gives wrong results. These all things has been taken care in this tool. I would recommend everyone for this tool. We should not alwys follow old things blindly when there is something innovative. I believe initially people would have not accepted selenium also but now everyone is using it.

    • @HYRTutorials
      @HYRTutorials  3 ปีที่แล้ว

      It looks like a promotion of some particular tool.
      If you read my comment clearly, you will get the point what I'm trying to convey.
      I'm not against or favourable to any tool.
      I'm just saying we should always learn about xpath, then only we should move on to using these add-ons or tools.

  • @dinokundukulam5689
    @dinokundukulam5689 3 ปีที่แล้ว +1

    I am not able to access the official page H Y R tutorials ???

    • @HYRTutorials
      @HYRTutorials  3 ปีที่แล้ว

      I just checked and it's working.

    • @dinokundukulam5689
      @dinokundukulam5689 3 ปีที่แล้ว

      @@HYRTutorials yeah now it's working . Actually I have an interview of amazon for automation analyst and they require xpath so this is enough to crack the interview or still there are other topics on xpath , I am a beginner , plz help me

    • @HYRTutorials
      @HYRTutorials  3 ปีที่แล้ว

      @@dinokundukulam5689 did u checkout my xpath playlist?
      If so these are enough.

    • @dinokundukulam5689
      @dinokundukulam5689 3 ปีที่แล้ว +1

      @@HYRTutorials Yes I have watched the 4 videos in the playlist

    • @HYRTutorials
      @HYRTutorials  3 ปีที่แล้ว

      @@dinokundukulam5689 Then it's enough.

  • @judseenaannie5670
    @judseenaannie5670 2 ปีที่แล้ว +1

    Sir I want all the front page titles as one x path

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      I guess that is not possible.
      If you want to get the title then u need to lang in that page then only you can get the title.
      So if we want all the titles then we need to navigate to each and evey page then get the title.

  • @RamaKrishna-or2cj
    @RamaKrishna-or2cj ปีที่แล้ว +1

    Can you explain xpath using last() sir??

    • @HYRTutorials
      @HYRTutorials  ปีที่แล้ว +1

      You can watch this video buddy
      th-cam.com/video/ilTFwMV3lHk/w-d-xo.html

    • @RamaKrishna-or2cj
      @RamaKrishna-or2cj ปีที่แล้ว

      Tqu👍

  • @satyanarayanas6769
    @satyanarayanas6769 2 ปีที่แล้ว +1

    slow voice when listening