Handle Dynamic Google Search Using Dynamic XPath - WebDriver Session - 15

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ก.ย. 2017
  • Handle Dynamic Search Using Dynamic XPath - Google Search:
    Steps:
    1. Google Search - pick a value from suggestions
    2. Search using Xpath
    3. Get the total count of suggestions
    4. Use if condition to match the value
    5. Click on matched value
    ===========================================
    Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
    / naveenautomationlabs
    Follow me on my Facebook Page:
    / naveenqtpexpert
    ~-~~-~~~-~~-~
    Follow my Site/Blog: www.naveenautomationlabs.com
    ========================================================
    Please watch: "Selenium & Automation Interview Preparation - By Naveen AutomationLabs"
    • Selenium & Automation ...
    ~-~~-~~~-~~-~ Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
    th-cam.com/users/Naveen%20Au...
    Follow me on my Facebook Page:
    / naveenqtpexpert
    Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:
    t.me/joinchat/COJqZUPB02r5sB7...
    Paid courses (Recorded) videos:
    Java & Selenium Course: www.naveenautomationlabs.com/p...
    API Course: www.naveenautomationlabs.com/p... ➡️Get Our Courses✔️
    📗 Get My Paid Courses at
    Paid courses (Recorded) videos:
    Java & Selenium Course: www.naveenautomationlabs.com/p...
    API Course: www.naveenautomationlabs.com/p...
    -------------------------------
    ✔️SOCIAL NETWORKS
    Facebook: / naveenqtpexpert
    Twitter: / naveenkhunteta
    Blog: www.naveenautomationlabs.com
    --------------------------------
    Support My Channel✔️Or Buy Me A Coffee
    Paypal: paypal.me/naveenkhunteta
    Google Pay: naveenanimation20@gmail.com
    --------------------------------
    ✔️Thanks for watching!
    देखने के लिए धन्यवाद
    Благодаря за гледането
    感谢您观看
    Merci d'avoir regardé
    Grazie per la visione
    Gracias por ver
    شكرا للمشاهدة
  • วิทยาศาสตร์และเทคโนโลยี

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

  • @hrusikeshbisoyi4252
    @hrusikeshbisoyi4252 5 ปีที่แล้ว +3

    During Coaching my Selenium, my Guru said this program. After see this video I recall that class memory. Thanq @naveen

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

    Dude, you freakn rock. keep continuing to help aspiring us to become proficient in Selenium!

  • @rrrindia13
    @rrrindia13 5 ปีที่แล้ว +2

    Thanks Naveen for such wonderful explanation. I love to watch your videos. Your teaching method is very interesting.

  • @santhoshk8095
    @santhoshk8095 6 ปีที่แล้ว +4

    hi naveen sir.. really u have great knowledge and ur spreading ur knowledge with all..Thank u so much sir...

  • @srinathsrinath24
    @srinathsrinath24 6 ปีที่แล้ว +2

    Hi Naveen, Amazing explanation always............We all appreciate your efforts.
    Thank you.

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

    Excellent bro, what an explanation. Interesting and Understanding.

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

    this video made my morning :) Very informative and "wowww" video.. Thank you so much Naveen... we all are blessed to have you as our guide....

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

    Naveen thanks you are excellent skills in automation testing

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

    Really appreciable, Amazing explanation

  • @user-wt1lu7kf9t
    @user-wt1lu7kf9t 5 หลายเดือนก่อน +2

    It's an amazing session to generate customised Xpath.

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

    Thanks, it is so detailed and covering all points.

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

    Excellent explanation. Thanks a lot.

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

    Thanks a lot Naveen. Very good topic you have covered. Keep it up😊

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

    Thank you sir. the video is very helpful

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

    Thanks man, it worked for me!

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

    Hi naveen awesome explanation thank you

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

    I am learning very much from your videos and day by day my concepts are getting cleared.thank you so much for point to point explanation and hates of for your great efforts.

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

    Great Explanation!!!

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

    Very useful tutorial, thank you!

  • @KirtiSharma-vs4wi
    @KirtiSharma-vs4wi 3 ปีที่แล้ว

    Instead of using descendant if we use li// div then also it will take the child div. right?

  • @samratdagde3349
    @samratdagde3349 ปีที่แล้ว

    Hi Naveen
    I want to ask one question..is there any option to do automation for canvas application ?

  • @meghraj
    @meghraj 6 ปีที่แล้ว +2

    really good concept.

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

    Hi Sir , very nice video andinformative I am new to selenium learning through your video are clearing my doubts in much better way . can you please explain more for descendant in which scenarios we use descendant in xpath .

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

    Thanks naveen for your videose they are very helpfull can u please make a video for CSS (Element locator) separate one with examples.

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

    Explaining in such a lucid way ... great, thanks !!! keep making us learn which will finally makes us earn too.. :P

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

    Hi Naveen, using find elements I am trying to do as you have shown in the video but on the web page I have 11 suggestions but when I am printing it's coming 1, checked the XPath it's correct. Can you please help me with this?
    Thanks.

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

    Naveen how did u selected the whole box before inspecting, i m sorry i cant do that like i search testing and the options came in the box i can nor select the whole box thats y i cant inspect. Can someone help here, sorry m still learning.

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

    Very good appreciate your knowledge..

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

    Great Explanation...

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

    Thank you so much Naveen ❤️

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

    Naveen, your tutorials are very helpful. Thank you very much

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

    at the last of div, if we have span , like the search value is show as testing , in this case what to do , what is the xpath syntax....

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

    Thank you, very interesting.

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

    Good Explanation 👌👌

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

    Thank you very much very useful

  • @ravinderjill9961
    @ravinderjill9961 6 ปีที่แล้ว

    in my project i lot of autocomplete text box, all the options are in div tags , i have used same which you explained in the video it is clicking third element even though i change the test of contains method

  • @deepakpatil2397
    @deepakpatil2397 5 ปีที่แล้ว

    Super Naveen Sir....

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

    hello naveen this code is not working can you please give me the Xpath (i am unable to find proper class for xpath) and i tried with sbct and sbtc both ..

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

    tq Naveen

  • @ramangandhi4221
    @ramangandhi4221 5 ปีที่แล้ว

    Sir I have implemented this but when I did automation testing on ibibo flights I am unable to select the destination, I found problem in finding the locator, I beleive it is angular js application and difficult to find the locator, sir please try it is some how different

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

    Thank You, Sir!

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

    thanks, Naveen.

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

    643(Sept 24, 2017) ---> 275K (June 22, 2022) Magic of compounding. Thanks for the video.

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

    sir can you please explain the auto suggest drop down for sites like redbus to get source and destination data to excel.

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

    I am watching your selenium videos.and believe me I'm becoming too good in selenium day by day. Your videos are very clear, concise and to the point. And these days, I'm attending interviews.
    I have couple of doubts. Please help me to clear.
    1. Why I always need to launch new browser every-time when I run selenium code. Why I won't run the selenium code in the same browser in which which I am currently working with my stuffs.
    --->Is there any method to do the same? Then please make a video tutorial to explain.
    2. Is there any method to fetch our the list of navigated browser history?
    Waiting for your reply.And Thank you so much for such amazing and cost free content

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

    Great explanation

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

    Thanks 😃.

  • @myfocus7447
    @myfocus7447 6 ปีที่แล้ว +2

    is there any training video from u on customization of x path

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

    very good explanation

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

    Hi Naveen.My auto suggestion is coming like searchbar in the left when running the script. Xpath and all are correct but due to this I am getting count as 0. while in original chrome it is giving auto suggestion not like this. Kindly solve this doubt

  • @mohdziaularfeen8882
    @mohdziaularfeen8882 9 หลายเดือนก่อน +1

    Thank you sir

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

    Hi Naveen, I have tried this multiple time but getting size 0. In the browser I am getting the size means able to inspect the element. Could anyone help me on this.

  • @myfocus7447
    @myfocus7447 6 ปีที่แล้ว +2

    useful . thanks for sharing

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

    Hi Naveen
    Output is not getting print on console with below code,Count is coming correct
    for (int i=0;i

  • @chiraggoel9423
    @chiraggoel9423 5 ปีที่แล้ว

    Hi Naveen,
    First of all, thanks a lot for preparing video lectures.
    I have a question on this video. You have used //li/descendant::div in the xpath, however I tried with //li//div. The number and type of elements returned were same in both the cases. So, are both the ways right of doing this or only in this case it is returning the same elements.
    If both are right way than is descendant equivalent to double slash ("//") and child equivalent to single slash ("/").
    You response is awaited.
    Thanks,
    Chirag

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

    I like ur video bcz u r telling real time scenario very nicee i want to talk with u o want to learn many things please help me

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

    Hello Naveen,
    Thankyou so much for your videos they are very helpful.
    Can you please explain the difference between / and // while writing xpath?
    As per my research what i found is / will make selenium search the tag immediate next to the search node,where // will enable selenium to search the entire document is it true?
    Please help me with your explaination on this.
    Thanks in advance.

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

    This is superb..this is what exactly I was looking for. Your explanation is very clear and simple.. Thank you.

  • @arupesh123
    @arupesh123 5 ปีที่แล้ว

    very helpful

  • @kanishkatyagi4708
    @kanishkatyagi4708 5 ปีที่แล้ว +2

    Hi naveen sir,
    I am using tha same code which ur explaining but still I am getting 0 elements as length.
    Do i need to use explicit wait before the code ??
    Please help me out!!

    • @shrimeenaravikumar6347
      @shrimeenaravikumar6347 5 ปีที่แล้ว

      iam also facing the same error

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

      Hi Kanishka, Implicit time lo, then code will run correctly.

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

      Hi Kanishka... I was facing the same issue. try by adding the following code
      Thread.sleep(1000);
      before fetching the suggestion list. Thanks.

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

    Awesome

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

    why we use colons while writing the dynamic expath

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

    Hi Naveen,
    There is an issue ---it is printing all suggestion if we are not clicking any element but if we are clicking any element then it is printing uptill that element only and rest of the suggested element are not printed.
    ------------
    Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 22951
    Only local connections are allowed.
    Dec 30, 2017 6:39:09 PM org.openqa.selenium.remote.ProtocolHandshake createSession
    INFO: Detected dialect: OSS
    *Total No. of sugggestion in Google search box::==>10*
    java
    javatpoint
    javascript
    java tutorial
    plz suggest!!

    • @naveenautomationlabs
      @naveenautomationlabs  6 ปีที่แล้ว

      are you using break in if condition?

    • @praveenautomationinterview2367
      @praveenautomationinterview2367 6 ปีที่แล้ว

      yes i am using break statement in if condition
      *for(int i=0;i

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

      do you guys have code snippet on how to get the total number of autosuggestion using selenium python? Thanks

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

    hi naveen,
    I need help, in my code, find.elements is returning empty list i dont know why.
    Just to try, I tried with the absolute xpath also but that is also giving null list.
    But i can see suggestions on google.
    Can you pls help me with this.

    • @BhardwajFamily1
      @BhardwajFamily1 5 ปีที่แล้ว

      Hi Sugandha,Please try withList list=driver.findElements(By.xpath("//ul[@role='listbox']//li/descendant::div[@class='sbl1']"));
      System.out.println("total number of suggestiong:"+list.size());
      for(int i=0;i

    • @Srhnu449
      @Srhnu449 5 ปีที่แล้ว

      @@BhardwajFamily1 its not working its showing empty for me .. have tried your code

    • @BhardwajFamily1
      @BhardwajFamily1 5 ปีที่แล้ว

      I will check and let you know

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

      @@BhardwajFamily1 we have to use implicitly wait then only its displaying the count and will click on the particular content. its working fine for me as well

    • @BhardwajFamily1
      @BhardwajFamily1 5 ปีที่แล้ว

      Ok, as I need to review my code, I will check this in evening and then only we can discuss

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

    I m not able to get the list printed on console but getting the size on it....plzz help

    • @BhardwajFamily1
      @BhardwajFamily1 5 ปีที่แล้ว

      List list=driver.findElements(By.xpath("//ul[@role='listbox']//li/descendant::div[@class='sbl1']"));
      System.out.println("total number of suggestiong:"+list.size());
      for(int i=0;i

  • @HowTo-so4oj
    @HowTo-so4oj 5 ปีที่แล้ว

    Hi Naveen, I wrote code for the google search but I am getting the error as an invalid selector. Now in the HTML code, inside tag there is a tag but does not have attribute then how to write that inside XPath if the attribute is not present.

    • @tanmaykumbhar9614
      @tanmaykumbhar9614 5 ปีที่แล้ว

      hey,
      Im also facing the same problem .
      Please help..
      its urgent..!!

  • @satishgangane6238
    @satishgangane6238 5 ปีที่แล้ว +4

    @naveen tutorial is great but just one quick question I am getting a after div where we select a particular choice out of suggestion list.. i guess due to that my dynamic xpath is not working ... is there any solution to it??

    • @manishakatare9943
      @manishakatare9943 4 ปีที่แล้ว +2

      due that my code is also not working

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

      Guys did resolve the error? Am also facing similar issue

    • @m.pavankumarreddy7399
      @m.pavankumarreddy7399 2 ปีที่แล้ว

      Yes same issue for me also any possible solution for this

  • @explore2536
    @explore2536 ปีที่แล้ว

    Hi
    How can we do the same using selenium python

  • @mounikakrishna5031
    @mounikakrishna5031 5 ปีที่แล้ว

    How to copy a field from excel and search(Ctrl+F) for it in a webpage using webdriver

  • @shabanabanu732
    @shabanabanu732 6 ปีที่แล้ว

    Hi naveen thanx I liked ur video so much, but please guide us how to install firepath and Firebug for chrome browser

    • @runningshorts6577
      @runningshorts6577 6 ปีที่แล้ว

      hehe...no fire path and fire bug is there for ch
      rome. they are addons only for fire fox......first understand the basics...

  • @MithunKumar-gh1et
    @MithunKumar-gh1et 6 ปีที่แล้ว +1

    Hi Naveen,
    Thanks for informative video, Can you please help on understanding excel operations using selenium

  • @rahulduari963
    @rahulduari963 11 หลายเดือนก่อน

    Great

  • @lavanyapitchuka1176
    @lavanyapitchuka1176 6 ปีที่แล้ว

    Hello Naveen, I have given the xpath for the search box and sendkeys, but it is not recognizing and not giving any recomendations for the search. Finally the result is showing that there are 0 recomendations for the search. Please help me.

    • @gcvkannada
      @gcvkannada 5 ปีที่แล้ว

      Try this script it will work.....
      System.setProperty("webdriver.chrome.driver", "C:\\chromedriver_win32\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
      driver.get("www.google.com");
      driver.findElement(By.xpath("//input[@id='lst-ib']")).sendKeys("selenium");
      //without descendant
      List ele = driver.findElements(By.xpath("//div[@class='sbqs_c']"));
      //with descendant
      //List ele = driver.findElements(By.xpath("//ul[@role='listbox']//li/descendant::div[@class='sbqs_c']"));
      System.out.println(ele.size());
      for(int i = 0; i

    • @akshay1379
      @akshay1379 5 ปีที่แล้ว

      Lavanya implicit time lo code me tab sahi chalega

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

    Hi Naveen . Great to see your videos. when i was practicing dynamic google search I am getting a after div where we select a particular choice out of suggestion list. i used the class as Sb11 but after that there is Span tag because of whihc i am getting total list as zero. could you please suggest . used the code as below
    List list = driver.findElements(By.xpath("//ul[@role='listbox']//li/descendant::div[@class='sb11']"));

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

      Hi@swapna M did you get a resolution?

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

      Use driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); after launching the browser if you haven't already. Also recheck the class name again since Google changes the code often.

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

    This ain't working. I am getting the size as 0. Also, the source code of google page has changed. please help.

  • @sachinkulkarni2255
    @sachinkulkarni2255 5 ปีที่แล้ว

    Wat if that has testingtutorial ? How can we write the xpath in this case ?

    • @anilkumarthota511
      @anilkumarthota511 5 ปีที่แล้ว

      xpath("//ul[@role='listbox']//li/descendant::div[@class='sbl1']")
      ignore span tag..Use div tag ,that contains search term and tags .....
      for me its worked properly....

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

      @@anilkumarthota511 it's not working

  • @foodygirls8424
    @foodygirls8424 ปีที่แล้ว

    How can we automate drag functionality in Google map

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

    hello Naveen i am waiting for your reply for my last comment in your video 9 session 7
    and today i am suffering with code
    List list = driver.findElements(By.xpath("//ui[@role='listbox']//li/descendant::div[@class='sbl1']"));
    System.out.println("total number ====>"+ list.size());

    for(int i=0; i

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

    I am trying to write xpath, but somehow it's not correct, can you please help me with updated one

  • @rupalilawate1543
    @rupalilawate1543 5 ปีที่แล้ว

    Hi Sir,
    i tried to find xpath for auto suggestions list but it not displaying the list of suggestions.

    • @BhardwajFamily1
      @BhardwajFamily1 5 ปีที่แล้ว

      List list=driver.findElements(By.xpath("//ul[@role='listbox']//li/descendant::div[@class='sbl1']"));
      System.out.println("total number of suggestiong:"+list.size());
      for(int i=0;i

    • @akshay1379
      @akshay1379 5 ปีที่แล้ว

      @@BhardwajFamily1 total number of suggestions 0 aa rahe hai

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

      Ok Sir, Implicittime lene per sahi chal raha hai code. Thankyou

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

    was asked in cognizant today

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

    How can we handle google address api search for application?

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

    can you explain the same concept by using google chrome ..??

    • @naveenautomationlabs
      @naveenautomationlabs  6 ปีที่แล้ว

      I'm using chrome browser only.

    • @anugantimukesh
      @anugantimukesh 6 ปีที่แล้ว

      sorry, u explain the top concept, by using firefox only....

  • @snehakejriwal7340
    @snehakejriwal7340 6 ปีที่แล้ว

    Hi Naveen,
    This is the exception i m getting while clicking on the second search bar on google.com
    Steps of my program:
    ---------------------------------------------
    search for java on google home page search bar
    choose java programs from suggestion and click
    click on searchbar
    choose java programs pdf from suggestion
    Exception in thread "main" org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
    (Session info: chrome=64.0.3282.119)
    (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 0 milliseconds
    For documentation on this error, please visit: seleniumhq.org/exceptions/stale_element_reference.html
    Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
    System info: host: 'F208', ip: '10.10.20.33', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_152'
    Driver info: org.openqa.selenium.chrome.ChromeDriver
    Capabilities {acceptSslCerts: true, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.33.506120 (e3e53437346286..., userDataDir: C:\Users\Sneha\AppData\Loca...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 64.0.3282.119, webStorageEnabled: true}
    Session ID: eac8002bf441e6d54cccf3be5664de73
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
    at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
    at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
    at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:279)
    at org.openqa.selenium.remote.RemoteWebElement.getText(RemoteWebElement.java:160)
    at co.edureka.selenium.webdriver.basic.GoogleSearchTestExampleWithDynamicXpath.searchJavaInGoogle(GoogleSearchTestExampleWithDynamicXpath.java:50)
    at co.edureka.selenium.webdriver.basic.GoogleSearchTestExampleWithDynamicXpath.main(GoogleSearchTestExampleWithDynamicXpath.java:61)
    please help me where did i went wrong i am not able to find the solution for this. Tried keeping static wait but still the exception remains same

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

    Hi Naveen,
    Thanks for this expalnation.I tried the same but i am gettiing Invalid selector Error.
    i have used this line to get the list:
    java.util.List list=driver.findElements(By.xpath("ul//[@role='listbox']//li/descendant::div[@class='sbqs_c']"))

    • @naveenautomationlabs
      @naveenautomationlabs  6 ปีที่แล้ว

      Coz Google search locator has been changed now.

    • @nidhishetty3021
      @nidhishetty3021 6 ปีที่แล้ว

      Naveen AutomationLabs
      No I believe it is what I have pasted here

    • @gcvkannada
      @gcvkannada 5 ปีที่แล้ว +2

      Check is your script contains wait/implicitlyWait statement or not... if not add wait it will work... it works with and without descendant.
      System.setProperty("webdriver.chrome.driver", "C:\\chromedriver_win32\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
      driver.get("www.google.com");
      driver.findElement(By.xpath("//input[@id='lst-ib']")).sendKeys("selenium");
      //without descendant
      List ele = driver.findElements(By.xpath("//div[@class='sbqs_c']"));
      //with descendant
      //List ele = driver.findElements(By.xpath("//ul[@role='listbox']//li/descendant::div[@class='sbqs_c']"));
      System.out.println(ele.size());
      for(int i = 0; i

    • @yogitzz.kulawade253
      @yogitzz.kulawade253 5 ปีที่แล้ว +1

      @@gcvkannada Thanks Vishnu.
      It was returning zero suggestions but after the use of Implictlywait ,it returned proper count.

    • @sharrifhussain2784
      @sharrifhussain2784 5 ปีที่แล้ว

      @@gcvkannada sir ya jisa tara ap na kia han ma na bikul isi tara kia han but console ma mara 0 ah rha han br br driver.findElement(By.name("q")).sendKeys("Java"); List list = driver.findElements(By.xpath("//ul[@role='listbox']//li/descendant::div[@class='sbl1']")); System.out.println("Total number of suggestions in search box:::===>" + list.size()); ya code han mara

  • @avengers1960
    @avengers1960 ปีที่แล้ว

    Hi Naveen, I have tried the tutoria, my doubt:
    Here is the WebElement
    testing
    openings in chennai
    In the above Webelement i am trying to use the code in Selenium
    Code in selenium:
    List list = driver.findElements(By.xpath("//ul[@role='listbox']//li/descendant::div[@class='wM6W7d']"));
    System.out.println("Total number of suggestions in search box:" + list.size());
    Output:
    Total number of suggestions in search box:0
    It is showing me 0 count but in chrome i can see 10 count.
    can you tell me whether my Custom Xpath is wrong ?

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

      Hi bro did you get your answer. I am also facing same issues. If you could help me it would be great.

  • @niteshrawat576
    @niteshrawat576 6 ปีที่แล้ว

    Hi All,
    Getting exception saying "invalid selector: Unable to locate an element......".
    This is the xpath i have used : //ul[@role='listbox']//li/descedant::div[@class='sbqs_c']
    Please help me solve the issue.
    Thanks in advance!

    • @sugandhajain7727
      @sugandhajain7727 6 ปีที่แล้ว

      pls write descendant

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

      Check is your script contains wait/implicitlyWait statement or not... if not add wait it will work... it works with and without descendant.
      System.setProperty("webdriver.chrome.driver", "C:\\chromedriver_win32\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
      driver.get("www.google.com");
      driver.findElement(By.xpath("//input[@id='lst-ib']")).sendKeys("selenium");
      //without descendant
      List ele = driver.findElements(By.xpath("//div[@class='sbqs_c']"));
      //with descendant
      //List ele = driver.findElements(By.xpath("//ul[@role='listbox']//li/descendant::div[@class='sbqs_c']"));
      System.out.println(ele.size());
      for(int i = 0; i

    • @learningcool1994
      @learningcool1994 5 ปีที่แล้ว

      HI, this code is not working with as well as without descendant. It is returning 0 list. Can you please explain how to solve this issue

    • @gcvkannada
      @gcvkannada 5 ปีที่แล้ว

      @@learningcool1994 , please past the full code, I will give a look. Thanks

    • @Srhnu449
      @Srhnu449 5 ปีที่แล้ว

      @@gcvkannada its working for me ... as u said i have added implicitly wait in my script .. its displaying the count and printing the content as well.
      thanks

  • @ShilpaShreemf
    @ShilpaShreemf 6 ปีที่แล้ว

    Hi Naveen, Thanks for the video on xpath concepts , which is very useful.
    Can you please let me know, difference between below 2 xpaths
    //ul[@id='something']//ul//descendant ::div[@class='xyz']
    //ul[@id='something']//ul//div[@class='xyz']
    What is the befinit we are getting by using 'descendant', the same can be achieved with //.

    • @1313durgesh
      @1313durgesh 2 ปีที่แล้ว

      //ul[@id='something']//ul//div[@class='xyz'] ------it works but ---- //ul[@id='something']//ul//descendant ::div[@class='xyz'] ------it doesn't work

  • @manaslenka5014
    @manaslenka5014 5 ปีที่แล้ว

    Sir , You have to put Explicit wait before listing the web element . because some time it gives count 0 , when we put the wait for that it always gives the right count .

    • @kianaj27
      @kianaj27 5 ปีที่แล้ว

      you just saved my day..i just had to implement a wait condition and it worked like a charm.

    • @akshay1379
      @akshay1379 5 ปีที่แล้ว

      Thanyou Manas Sir, now its working by taking implicit time.

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

    Naveen, can i have your email please, i need help writing xpath. Thank you

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

      Watch all his Xpath videos you will be in a great position to write xpath yourself.
      Good luck

  • @sharrifhussain2784
    @sharrifhussain2784 5 ปีที่แล้ว

    sir ya jisa tara ap na kia han ma na bikul isi tara kia han but console ma mara 0 ah rha han br br
    driver.findElement(By.name("q")).sendKeys("Java");
    List list = driver.findElements(By.xpath("//ul[@role='listbox']//li/descendant::div[@class='sbl1']"));
    System.out.println("Total number of suggestions in search box:::===>" + list.size());
    ya code han mara

    • @jasmeensingh940
      @jasmeensingh940 5 ปีที่แล้ว

      Hi sharrif,
      Please try to put implicit wait function after you navigate to Chrome. Because the Chrome is not able to read the elements on the page after you write "Java".
      driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

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

    purely XPath based programme

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

    sir i am facing some issue in this program please help me out

    • @BhardwajFamily1
      @BhardwajFamily1 5 ปีที่แล้ว

      List list=driver.findElements(By.xpath("//ul[@role='listbox']//li/descendant::div[@class='sbl1']"));
      System.out.println("total number of suggestion:"+list.size());
      for(int i=0;i

    • @babithkumarreddy7986
      @babithkumarreddy7986 5 ปีที่แล้ว

      @@BhardwajFamily1 if(list.get(i).getText().contains("Testing Techniques") . Try like this Bhardwaj

    • @BhardwajFamily1
      @BhardwajFamily1 5 ปีที่แล้ว

      @@babithkumarreddy7986 for better result use equals, if we will use contains our compiler will be confused which result it has to click

  • @RutujaMisal-xg5bq
    @RutujaMisal-xg5bq หลายเดือนก่อน

    very difficult steps please explain in only easy way .

  • @naemislam7148
    @naemislam7148 5 ปีที่แล้ว

    thanks for this tutorial
    Please give me this code...

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

    Thanks but you made this video too long

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

    if is present inside last tag, or if the list.size()=0 try webdriverwait():
    List options = new WebDriverWait(driver, 10).until(ExpectedConditions.numberOfElementsToBeMoreThan(By.xpath("//ul[@role='listbox']//li/descendant::span"), 0));
    System.out.println("no. of suggestions:"+options.size());

    for(int i=0;i

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

    Those who are facing issue and confused with span tag in between can try this xpath:-
    List list=driver.findElements(By.xpath("//ul[@role='listbox' and @class='G43f7e']/parent::div[@class='OBMEnb']//preceding-sibling::div[@class='mkHrUc']//li/descendant::div[@class='wM6W7d WggQGd']"));

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

      Also, if you are getting count as 0 make sure you give explicit wait just before writing your xpath

    • @ritabrataghorai2144
      @ritabrataghorai2144 ปีที่แล้ว

      Thanks bro,it works