No video

How to Handle Multiple Windows or Tabs in Selenium Webdriver

  Рет қаралды 170,746

Mukesh otwani

Mukesh otwani

Күн бұрын

This video will guide you How to Handle Multiple Windows or Tabs in Selenium Webdriver.
Using Set interface and using getWindowHandles we can handle multiple tabs in Selenium Webdriver.
Must listen before going through this video
• What is Set Interface ...
learn-automation.com/handle-mu...
~-~~-~~~-~~-~
Please watch: "How To Create Maven build For Selenium Framework"
• How To Create Maven bu...
~-~~-~~~-~~-~

Пікірлер: 212
@alexandrutudosan3319
@alexandrutudosan3319 3 жыл бұрын
best video on window handler!!
@Mukeshotwani
@Mukeshotwani 3 жыл бұрын
Thanks Alex 😊
@666giraldo666
@666giraldo666 6 жыл бұрын
Duuuuuude you are my savior, I had been trying to do this for over 5 hours and after 13 minutes of your video it worked! thanks!
@snehamazumder2315
@snehamazumder2315 7 жыл бұрын
Thanks for the wonderful explaination.Cleared all the basic concepts of Sets,Lists and their application in handling multiple tabs in Selenium Webdriver.
@AnirudhGarg1123
@AnirudhGarg1123 7 жыл бұрын
Please do something for audio disturbance. Content is great.
@maroofraktim293
@maroofraktim293 3 ай бұрын
Indeed, this is the best video on window handling. Keep up the good work.
@Mukeshotwani
@Mukeshotwani 2 ай бұрын
Thank you so much
@darkflame4441
@darkflame4441 3 жыл бұрын
Great video bro, can’t believe so many dislikes because a bit of background noise. But the content is one of the best I’ve seen.
@Mukeshotwani
@Mukeshotwani 3 жыл бұрын
Thank you mate, this comment means alot to me.
@uditmanerikar2355
@uditmanerikar2355 3 жыл бұрын
Hello sir.your genuine effort to teach can be seen.channel would grow for sure.
@praveenjaldawar2652
@praveenjaldawar2652 4 жыл бұрын
Hi Mukesh, Superb explaination of handling popups with debugging..Thank you very much.
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Thanks Praveen :)
@animolshameer2355
@animolshameer2355 4 жыл бұрын
Thanks for your detailed description and it was really useful!!!
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Thanks Animol
@Rahulkumar-su5jd
@Rahulkumar-su5jd 4 жыл бұрын
@@Mukeshotwani hi sir how to handle if you click to 1 link then open 2nd tab then go to 2nd tab and in 2nd tab available one link then click that link then open 3rd tab then how to perform in 3rd tab any thing. plzzz sir reply me
@jitendrasheliya2301
@jitendrasheliya2301 5 жыл бұрын
Very Very Useful, thank you Mukesh.
@dhru2512
@dhru2512 6 жыл бұрын
NIce work and explanation brother Keep up the good work and i am really looking forward to the upcoming new videos.
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
Hi Pathak ji, stay tunned I have planned multiple videos in 2018..
@juliagutorova5807
@juliagutorova5807 3 жыл бұрын
Thanks, really good explanation!
@gopitn5864
@gopitn5864 5 жыл бұрын
Thanks...video helps me to solve my problem...good explanation..Thanks once again
@Mukeshotwani
@Mukeshotwani 5 жыл бұрын
Thanks Gopi I am glad it helped you.
@kirtibanga8292
@kirtibanga8292 3 жыл бұрын
Thank you for wonderful video. This is very informative.
@arpitapanda9428
@arpitapanda9428 6 жыл бұрын
Thanks Mukesh ji, I feel automation using Selenium is easy now, lots of thanks to your valuable videos. Looking forward to more such videos in 2018.
@divyar5116
@divyar5116 5 жыл бұрын
Thanku very much. Nice explanation.
@Mukeshotwani
@Mukeshotwani 5 жыл бұрын
Thanks Divya :)
@aayushpatel3360
@aayushpatel3360 3 жыл бұрын
awesome sir, really much helpful
@krishnavamsi9795
@krishnavamsi9795 3 жыл бұрын
Feel like best of all explanations loved ot sir ty
@Mukeshotwani
@Mukeshotwani 3 жыл бұрын
So nice of you Krishna thank you.
@GagandeepKaur-jh6tw
@GagandeepKaur-jh6tw 3 жыл бұрын
Hi Mukesh. I have a question. Like you have mentioned we can convert set to ArrayList and then we can use indexes to switch to windows. Can we do sth like this: LinkedHashSet windows=driver.getWindowHandles(); and then use the indexes as LInkedHashSet maintains the insertion order?
@venkateshgampa619
@venkateshgampa619 7 жыл бұрын
Hi your videos are very helpful thank you
@Mukeshotwani
@Mukeshotwani 7 жыл бұрын
Most welcome Mate :) Keep visiting.
@SanjayYadav-xw9zj
@SanjayYadav-xw9zj 6 жыл бұрын
Awesome explaination @Mukesh Otwani 👍👍
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
Thanks Sanjay.. I am glad you liked my videos.
@Rahulkumar-su5jd
@Rahulkumar-su5jd 4 жыл бұрын
​@@Mukeshotwani please make a video on how to switch from parent to child then again a new child window
@saurabhshirsath1755
@saurabhshirsath1755 2 жыл бұрын
Thanks for this wonderful explanation.
@Mukeshotwani
@Mukeshotwani Жыл бұрын
Glad it was helpful! Saurabh
@thebgagabati
@thebgagabati 4 жыл бұрын
Thanks. This is working for me now.
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Great
@sandeepnehte3094
@sandeepnehte3094 7 жыл бұрын
Hi Mukesh, i like your all shared videos, i am Automation Tester(Selenium) , i have a request that can you please upload video for "How to read and verify pdf content in Selenium Webdriver" ??
@seenukaniappan8882
@seenukaniappan8882 6 жыл бұрын
Keep Rocking !
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
+Seenu Kaniappan 😀
@Pranit_Singh
@Pranit_Singh 7 жыл бұрын
Hello Mukesh, I really admire what you have been doing. I find it as the best source to learn selenium. I do have a question regarding the mac "/usr/local/bin" folder. I always use system.setProperty, as I cannot access the BIN folder on my MAC as it says no such folder found. After searching on google it says if my mac is upgraded to El Capitan, i can't access the bin folder. Is there any other way to access the bin folder, so that I don't have to type System.setProperty, in every program. Thanks in Advance.
@shanmugasrinivas8004
@shanmugasrinivas8004 Жыл бұрын
Very helpful for me, Thank you
@Mukeshotwani
@Mukeshotwani Жыл бұрын
Glad it was helpful! Tahnks Shanmuga
@Bit2BOSS
@Bit2BOSS 7 жыл бұрын
Hi Mukesh, that was so good and worth learning. However, I have a problem similar to this. Can we have a discussion please?
@jalpabhatt9949
@jalpabhatt9949 7 жыл бұрын
If insertion order is not preserved in Set then how can we get sequential order in getWindowHandles? Shouldn't pop up/new tab id be assigned in random order and come out in random order in Set??
@himanis6821
@himanis6821 3 жыл бұрын
Hello Sir, do we use the same code for switching to new tab and new window after click of any link ?
@arvinderpreetsingh410
@arvinderpreetsingh410 7 жыл бұрын
The set which is holding all the Windows will be unordered. Then how can we switch to a particular window (correct index is still unknown)using get index method of arraylist.
@mohammedmusthafa2444
@mohammedmusthafa2444 4 жыл бұрын
Hi Mukesh, This video is comparatively good. You explained very well.. Thanks for posting this Video.. I 'm actually facing an issue with switching between the tabs in headless mode for the same scenario u mentioned.. I get timeout error received message renderer exception and test fails.. Have you ever come across this issue? And do you have any possible solution for my case? Any suggestions and workaround is highly appreciated.. Thanks in advance. Good Luck.!
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Hey Mohammed, here is the link for solution kzfaq.info/get/bejne/eZ53qLSHzqyoY40.html
@rupjitdas8509
@rupjitdas8509 4 жыл бұрын
Hi Mukesh, set doesn't preserve the order, so in handling multiple windows also this will not be preserved and hence on converting the set to list we may get the order of windowids in different order in every run, which might cause problem, so do you suggest to switch to each window and verify the title first and then proceed with respective window testcases? Or there is some other easy approach?
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Hi Rupjit, getWindowHandles follow LinkedHashSet so it will have value based on order. For example if you open tab 1, tab2, tab3 then it preserve the order.
@rubalverma4930
@rubalverma4930 2 жыл бұрын
HI Mukesh, while switching to next window in IE browser, am getting "NoSuchWindowException : unable to get browser " could you please help me out in this
@shibiyazhini8692
@shibiyazhini8692 6 жыл бұрын
hi, sendkeys keyword is not working in chrome. the same code i have tried running it on Firefox, its working fine. could you help out in this?
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
HI Shibi, Ideally it should work.. Please use latest chrome driver 2.38 chromedriver.storage.googleapis.com/index.html?path=2.38/
@RajuDas-zn3gx
@RajuDas-zn3gx 6 жыл бұрын
Hi Mukesh thank you for this video. I followed each and every for first example where I have 2 windows and count gives 2 as well but control does not switch to new window. Please help me to solve this problem. What do you think reasons behind not focussing on new window
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
Hi Raju which browser you are using for Switching?
@RajuDas-zn3gx
@RajuDas-zn3gx 6 жыл бұрын
i am using internet explorer
@BidyasagarKapaliQA
@BidyasagarKapaliQA 6 жыл бұрын
Hi Mukesh, Thanks for the great session, like all other videos. Just want to know how can we handle the notification window that u can see in Naukri page (GeoLocation with 'Sure' and 'Later' Options) I tried with all possibilities, chrome options. But no luck. would you please help me with that. Thanks in advance.
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
Hi Kapali, This always works for me learn-automation.com/disable-chrome-notifications-selenium-webdriver/
@BidyasagarKapaliQA
@BidyasagarKapaliQA 6 жыл бұрын
Thank you. I shall try that. :)
@rajeshbe2234
@rajeshbe2234 5 жыл бұрын
Sir totally one parent window has 3childs windows so I want to open each window individually then I have to perform some operation on each and every window and switch between each window randomly so I tried like this but I couldn't do so please say how to do?
@rajeshbe2234
@rajeshbe2234 5 жыл бұрын
Sir how handle multi windows at a time b/w switch them with the single loop ?
@Ashirbadratha
@Ashirbadratha 5 жыл бұрын
Hi Mukesh, I have one scenario. Lets say i click on some link and as a result 2 popup window opened up. Now the requirement is that i need to navigate to second and perform some action and i need to switch to the first popup(not to the parent). So how to handle this case.
@Mukeshotwani
@Mukeshotwani 5 жыл бұрын
Hi Abhisek as I mentioned in the video that once you get all windows as List then you can traverse in any direction.
@saakshib7490
@saakshib7490 5 жыл бұрын
All your videos are excellent. Its my request please don't used enhanced for loop while explaining any topic ,it is difficult to understand flow :)
@Mukeshotwani
@Mukeshotwani 5 жыл бұрын
Sure Saakshi noted your points. I will cover for basic for loop and enhanced for loop as well.
@saakshib7490
@saakshib7490 5 жыл бұрын
@@Mukeshotwani Thank you sir :)
@priyavijayakumar1509
@priyavijayakumar1509 7 жыл бұрын
HI mukesh ! Do u have tutorials on javascript ?If no,can u pls suggest a good youtube link for the same?I wanna learn javascript! thanx in advance !
@chaitanyaakula4018
@chaitanyaakula4018 5 жыл бұрын
I tired this in ie browser...but the window handler Id's for all the opened tabs are same..please suggest how to handle tabs/windows in IE browser
@Mukeshotwani
@Mukeshotwani 5 жыл бұрын
Please change of IE browser settings
@AbhishekMishra-ru2fi
@AbhishekMishra-ru2fi 4 жыл бұрын
Mukesh, how to ensure we are going to window in the order they opened?Because Set has random contents each time.This is the interview question.Plz clarify asap.
@arunr8694
@arunr8694 2 жыл бұрын
Hi Mukesh, if I'm in second window and go to third window and then back to second window means , how to handle this
@MukundEquityMagic
@MukundEquityMagic 2 жыл бұрын
thank you
@parthjangid3587
@parthjangid3587 4 жыл бұрын
the logic which u have shown in above video 'll it work if we have more than 2 tabs or upto 100 or even more ?
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Hi Parth, yes it is applicable.
@pujithaa9973
@pujithaa9973 4 жыл бұрын
Hi Mukesh, Can you please explain how to switch b/w 4 tabs and perform actions on all 4 tabs..Please give suggestions
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Hi Pujitha, you can store them as list as I explained in below and then you can use index for switching.
@Bujji28243
@Bujji28243 6 жыл бұрын
it a great video it's work good but can we handle windows through title names????
@rameshbangaru2710
@rameshbangaru2710 4 жыл бұрын
Thank you very much mukesh garu..my all doubts clear about windowhandles with your video ...i have one small doubt with set interface we can handle tabs or not means tab by tab you used array list na thats y iam asking......
@A_philodendron
@A_philodendron 4 жыл бұрын
We converted set into array list as, in set we cannot use indexing option. And we directly can't store window handle elements in array list as selenium internally gives result in the form of set. So we need to store in set and then can convert to list if we need to use indexing option.
@karthikakn6510
@karthikakn6510 7 жыл бұрын
Thanku mukesh
@nancybhardwaj3895
@nancybhardwaj3895 3 жыл бұрын
Thank you Mukesh
@sankalpboradkar8682
@sankalpboradkar8682 6 жыл бұрын
Hello Can you please tell how to open multiple tabs in the same window
@sanjupole1491
@sanjupole1491 4 жыл бұрын
Why do we need to convert set into arraylist? Please explain.
@veera.akasapu
@veera.akasapu 3 жыл бұрын
Thank you
@Mukeshotwani
@Mukeshotwani 3 жыл бұрын
You're welcome Veera
@user-durga_sankar
@user-durga_sankar 7 ай бұрын
Hi Mukesh. Your all Videos are very very useful. Thank You so much. Just one thing.. if it can be taken care.. sound is less for some of the videos.
@Mukeshotwani
@Mukeshotwani 7 ай бұрын
Sorry for that sound issue. Now audio is better I will record video soon with good sound as well.
@user-durga_sankar
@user-durga_sankar 7 ай бұрын
@@Mukeshotwani Thank You so much.
@vijitha1236
@vijitha1236 3 жыл бұрын
I have tried to sign in bookmyshow site through continue with google but I couldnot navigate to the other window could you pls help me
@SaikiranPalugula
@SaikiranPalugula 7 жыл бұрын
Thank you very much Mukesh:-) If possible plz post some videos on C# for Selenium.
@SaikiranPalugula
@SaikiranPalugula 7 жыл бұрын
I didn't get you Brian...
@sangamsood5651
@sangamsood5651 5 жыл бұрын
i want to select 2nd value of index for multiple dropdown in one class
@venkatjakkepalli4833
@venkatjakkepalli4833 4 жыл бұрын
How to switch to incognito window form normal window, because while getting getWindowHandles() method getting only the normal windows ID'S not the incognito window ID's..please suggest us how to shift in between the two windows if one of the window is in incognito mode
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Hi Venkat, by default Selenium starts fresh session so why you need to start incognito windows?
@venkatjakkepalli4833
@venkatjakkepalli4833 4 жыл бұрын
@@Mukeshotwani in my requirement: checking the restriction of user login a application.so i opened the another window in incognito and checking it..so please suggest us to shift to incognito from normal window.
@bharathikamma8998
@bharathikamma8998 4 жыл бұрын
Hi Mukesh, why you have used set interface instead of list directly.
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Hi Bharathi, getWindowHandles return Set so first we need to store in Set
@sasmitamandal820
@sasmitamandal820 3 жыл бұрын
Hi Mukesh, Very nice video. I have one question. I am trying to navigate a url in a new opened tab in IE .As explained I followed everything. I am able to open tab but unable to open url . Even I tried by switching with child window I'd.. Kindly suggest
@Mukeshotwani
@Mukeshotwani 3 жыл бұрын
Hi Sasmita, for IE you might have to change registry value.
@sutapapramanick4692
@sutapapramanick4692 3 жыл бұрын
best video
@Mukeshotwani
@Mukeshotwani 3 жыл бұрын
Thanks Sutapa
@KumarSatyajeet
@KumarSatyajeet 6 жыл бұрын
If in the child window, we will get another window then how to handle this sub-child window?
@sangeethkumar9190
@sangeethkumar9190 2 жыл бұрын
Hi Mukesh, Set will not maintain any insertion order,If we are passing set (All saved window is )in List which maintains insertion order,In which order it will be stored. If we are accesing list.get(3) How can we ensure it is in the third window. It is the interview question where I am unable to explain properly.Could you help here
@tapaskhandai
@tapaskhandai 3 жыл бұрын
Hi Mukesh, how we will be sure that when we convert from set to list it will be stored in the same order in which order we wanted it to be?
@Mukeshotwani
@Mukeshotwani 3 жыл бұрын
Hi Tapas, getWindowHandles use LinkedHashSet internally so in which order windows will open you will get same order in List too.
@tapaskhandai
@tapaskhandai 3 жыл бұрын
@@Mukeshotwani Thank You Mukesh for clearing my doubt.
@Wanderlust_Naveen
@Wanderlust_Naveen 3 жыл бұрын
Hi small doubt sir..actually after login to one website,it's going to new window, I need to handle it..if I give xpath of one element in next window..it is not calculating.please help me
@Mukeshotwani
@Mukeshotwani 3 жыл бұрын
Hi Naveen, what is the issue here? After switching you can work with any webelement on new window.
@sarmisthatripathy3232
@sarmisthatripathy3232 4 жыл бұрын
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"*[name='q']"} Getting above error during run time .. How to handle this error? Can you please help me out?
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Yes Sarmistha, please share complete program so that I can guide you. As per exception your script is not able to find element.
@praveenjaldawar2652
@praveenjaldawar2652 4 жыл бұрын
Hi Mukesh, when i run above code, i got error i.e Child window title is Jobs - Recruitment - Job Search - Employment -Job Vacancies - Naukri.com and also exception got NoSuchSessionException. please help
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Hi Praveen, please share program.
@parulisha
@parulisha 6 жыл бұрын
I launched two browsers and tried to switch between these two using getwindowhandle. But in set it is only returning the current window. Used Code: String currentWindow = driver.getWindowHandle(); Set availableWindows = driver.getWindowHandles(); Why is it?
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
+parul khullar when you launch two browser then you will have two different instance so you can use both the instance separately. Switch window works when you have launched one window and then from that window if you open another tab or window then you will get count
@parulisha
@parulisha 6 жыл бұрын
Mukesh otwani thanks for your quick response. How can that be acheived. Even if I store windowhandles for both the browsers how will the switching be done.its like I have opened first and second browser, and currently I am on second one, and I need to switch. Can you guide
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
I will try to create video on this soon. Driver1 handle first browser Driver2 handle another browser Use above instance to handle respective browsers
@parulisha
@parulisha 6 жыл бұрын
That will be great.
@parulisha
@parulisha 6 жыл бұрын
Would be helpful if you can share some part of code here thanks,!
@deekshithb5459
@deekshithb5459 5 жыл бұрын
master , i have a doubt here why ur converting SET into LIST what is the reason.........
@Mukeshotwani
@Mukeshotwani 5 жыл бұрын
Hi Deekshith, not required but using this you can iterate via index as well. Set does not allow index so when we convert Set into List traversing can be easier. List in Java - kzfaq.info/get/bejne/hayajKRhxta9d40.html Set in Java- kzfaq.info/get/bejne/mbF0aMelv5_RaYk.html
@neetigoyal9075
@neetigoyal9075 4 жыл бұрын
nice video
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Thanks Neeti, welcome back to the channel
@neetigoyal9075
@neetigoyal9075 4 жыл бұрын
@@Mukeshotwani Thanks Mukesh , i was still following your video offline .I have saved all your videos . But some flavour of comments was missing , so started back with online videos only ...:) Anyway thanks for your warm welcome
@YashPratap009
@YashPratap009 6 жыл бұрын
Sir still facing audio disturbance though your explanation is awesome but bcz of bad audio quality you got 7 dislikes otherwise no one can xplain better then you...kudos to you...blessings
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
Yes Yash I am trying my best for Audio but some how audio is not up to mark. I will still try.. Thanks for nice comment.
@archanatiwari7574
@archanatiwari7574 5 жыл бұрын
Hi Mukesh, Can you please explain what is the difference between switching to windows and switching to tab?
@Mukeshotwani
@Mukeshotwani 5 жыл бұрын
For selenium both are same. Same command and same approach will work
@archanatiwari7574
@archanatiwari7574 5 жыл бұрын
@@Mukeshotwani okay thanks Mukesh
@Mukeshotwani
@Mukeshotwani 5 жыл бұрын
Cheers
@suryachintha1795
@suryachintha1795 3 жыл бұрын
@@Mukeshotwani Thanks Mukesh ..i have one doubt here .if that is the case then why we need to store the tabs again in the List .we can proceed (or iterate through) set only right
@malikah7145
@malikah7145 3 жыл бұрын
how is the start session on same window ?
@Mukeshotwani
@Mukeshotwani 2 жыл бұрын
Hi Malikah, if link opens in same window then no need to handle.
@manjunathah9025
@manjunathah9025 3 жыл бұрын
Mukesh, where are you setting the driver path in your code?
@Mukeshotwani
@Mukeshotwani 3 жыл бұрын
Hi Manjunatha, here is the video for same kzfaq.info/get/bejne/qbqUi8il2dOVqWw.html
@manjunathah9025
@manjunathah9025 3 жыл бұрын
@@Mukeshotwani appreciate your reply. Got the answer. Even you talked about using DriverManager also. Helpful. 👍
@manjunathah9025
@manjunathah9025 3 жыл бұрын
@Mukesh, I have one more doubt related to using single driver instance across multiple test case execution. Every time new driver instance is opened for test case execution, which I don't want to do it and also am not calling any driver. Close() method in @afterClass() annotation.
@Mukeshotwani
@Mukeshotwani 3 жыл бұрын
please share your code
@thems444
@thems444 Жыл бұрын
Please make on the Selenium in JavaScript also.
@mohitsachdeva9374
@mohitsachdeva9374 6 жыл бұрын
Sir its not going under if condition. I am writing the correct code but its still not entering the if condition package forms; import java.util.Iterator; import java.util.Set; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.Select; public class EdufectFormFullTest { public static void main(String[] args) { // TODO Auto-generated method stub String baseUrl="localhost:8080/WebApplication6/BasicForm1.jsp"; String name = "Mohit Sachdeva"; String age = "22"; String gender = "Male"; String line1 = "House No 401, Pocket 3"; String line2 = "Janta Flats, Paschim Puri"; String city = "New Delhi"; String zipcode = "110063"; String email = "mohitsachdeva.ms@gmail.com"; String mobile = "9999360340"; String working = "Yes"; String experience = "1"; String workUrl="localhost:8080/WebApplication6/WorkingDetails.jsp"; String namecomp="Edufect"; String designation="Java Trainee"; String background="Netbeans"; String year = "2018"; String salary = "10000"; String relocate = "No"; String projectLocation = System.getProperty("user.dir"); System.setProperty("webdriver.chrome.driver", projectLocation+"\\lib\\chromedriver\\chromedriver.exe" ); WebDriver driver = new ChromeDriver(); driver.get(baseUrl); driver.findElement(By.id("name")).sendKeys(name); driver.findElement(By.id("age")).sendKeys(age); WebElement radio1 = driver.findElement(By.id("male")); WebElement radio2 = driver.findElement(By.id("female")); if(gender.equals("Male")) { //Radio Button1 is selected radio1.click(); System.out.println("Radio Button Option 1 Selected"); } if(gender.equals("Female")) { //Radio Button2 is selected radio2.click(); System.out.println("Radio Button Option 2 Selected"); } driver.findElement(By.id("line1")).sendKeys(line1); driver.findElement(By.id("line2")).sendKeys(line2); driver.findElement(By.id("city")).sendKeys(city); driver.findElement(By.id("zipcode")).sendKeys(zipcode); driver.findElement(By.id("email")).sendKeys(email); driver.findElement(By.id("mobile")).sendKeys(mobile); // Selecting CheckBox WebElement option1 = driver.findElement(By.id("working")); // This will Toggle the Check box if(working.equals("Yes")) { option1.click(); } // Check whether the Check box is toggled on if (option1.isSelected()) { System.out.println("Checkbox is Toggled On"); } else { System.out.println("Checkbox is Toggled Off"); } Select drpCountry = new Select(driver.findElement(By.name("experience"))); drpCountry.selectByVisibleText(experience); driver.findElement(By.id("Submit")).submit(); System.out.println("Login Done with Submit"); if(gender.equals("null")) { driver.findElement(By.id("BasicForm1")).click(); System.out.println("Back to Basic Form"); } if(working.equals("null")) { } else { String parent=driver.getWindowHandle(); driver.findElement(By.id("WorkingDetails")).click(); System.out.println("Now Fill Working Details"); // To handle all new opened window. Set allWindows = driver.getWindowHandles(); for(String child:allWindows) { if(!parent.equalsIgnoreCase(child)) { driver.switchTo().window(workUrl); driver.findElement(By.id("namecomp")).sendKeys(namecomp); driver.findElement(By.id("designation")).sendKeys(designation); Select bground = new Select(driver.findElement(By.name("background"))); bground.selectByVisibleText(background); Select y = new Select(driver.findElement(By.name("year"))); y.selectByVisibleText(year); driver.findElement(By.id("salary")).sendKeys(salary); WebElement r1 = driver.findElement(By.id("Yes")); WebElement r2 = driver.findElement(By.id("No")); if(relocate.equals("Yes")) { //Radio Button1 is selected r1.click(); System.out.println("Radio Button Option 1 Selected"); } if(relocate.equals("No")) { //Radio Button2 is selected r2.click(); System.out.println("Radio Button Option 2 Selected"); } driver.findElement(By.id("SubmitPassport")).submit(); System.out.println("Login Done for Submit Passport"); } } } } }
@ramankumar1487
@ramankumar1487 5 жыл бұрын
please make a video on how to switch from parent to child then again a new child window
@mohitgoel9596
@mohitgoel9596 7 жыл бұрын
please make an tutorial in findbys and findAll
@jatinqa4020
@jatinqa4020 Жыл бұрын
Hi mukesh sir, I wanna know that how to pass data from one page to another
@Mukeshotwani
@Mukeshotwani Жыл бұрын
Hi Jatin, you can return the values from methods and you can accept in next page.
@onlyuser8374
@onlyuser8374 3 жыл бұрын
how to automate the existing window or tab ,without opening new browser or tab
@akashsinha4583
@akashsinha4583 6 жыл бұрын
sir its not working its opening the tab and not navigate to that window
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
Hi Akash, may be some code issue. Please send code to mukeshotwani@learn-automation.com
@dineshkumaar2117
@dineshkumaar2117 3 жыл бұрын
Very Good explanation , but lot of audio disturbance
@dabbark
@dabbark 5 жыл бұрын
Nice video. Thanks for sharing. I am facing some issue with the below code. With this code, it is actually closing the main window first and then closing the child windows and finally displaying "NoSuchSessionException". Please let me know what is the issue with the code. import java.util.Set; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class WindowsHandlingTest { public static WebDriver driver; public static void main(String[] args) throws InterruptedException { System.setProperty("webdriver.chrome.driver", chromeDriverPath); driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get("naukri.com"); String parent = driver.getWindowHandle(); System.out.println("Parent window id is " + parent); Set allWindows = driver.getWindowHandles(); for (String child : allWindows) { if (!parent.equalsIgnoreCase(child)) driver.switchTo().window(child); Thread.sleep(3000); driver.close(); } driver.switchTo().window(parent); System.out.println("Parent window title is " + driver.getTitle()); } }
@dipalisanas3914
@dipalisanas3914 3 жыл бұрын
A lot of audio disturbance, but helpful session thank you.
@Mukeshotwani
@Mukeshotwani 3 жыл бұрын
Thanks Dipali I am working on the audio part... 🙏
@RuchiSingh-jo7dc
@RuchiSingh-jo7dc 4 жыл бұрын
If I want to scroll child page instead of parents then how it will be possible?
@deepusingla6882
@deepusingla6882 4 жыл бұрын
how we can connect our idm with python to download
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Hi Deepu, Sorry I did not understand your question. Can you please elaborate?
@deepusingla6882
@deepusingla6882 4 жыл бұрын
Sir i am trying to make a downloader which will extract the link and download it through idm(internet download manger)
@rajeshbe2234
@rajeshbe2234 6 жыл бұрын
Nice bro but still u better to explain clearly some words can't understand audio is not perfect somewhat better
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
HI Rajesh this video is old try new video kzfaq.info/get/bejne/psCUgNZ9sKfOo2g.html
@mohammedvaseem3562
@mohammedvaseem3562 4 жыл бұрын
Hi Mukesh, Thank you for providing valuable content. I had executed this program in Chrome it worked fine. But when i ran the same in firefox driver (by providing required firefox drivers) it got error. Thanks for the help in advance! package MouseActions; import java.util.Set; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class WindowHandling3 { public static void main(String[] args) throws InterruptedException { System.setProperty("webdriver.gecko.driver", "E:\\Software Setups\\Gecko\\Gecko Mozilla\\geckodriver.exe"); WebDriver driver= new FirefoxDriver(); driver.manage().window().maximize(); driver.get("seleniumpractise.blogspot.com/2017/"); String parent = driver.getWindowHandle(); System.out.println("Parent value "+parent); driver.findElement(By.xpath("//a[contains(@href,'www.google.com')]")).click(); Set a = driver.getWindowHandles(); System.out.println("Window count size : "+a.size()); System.out.println("Set values data : "+a); for(String child:a) { System.out.println("Value of child: "+child); if(!parent.equalsIgnoreCase(child)) { System.out.println("Under If condition"); driver.switchTo().window(child); System.out.println("Driver Title: "+driver.getTitle()); System.out.println("Before statements"); driver.findElement(By.name("q")).sendKeys("selenium");; //driver.findElement(By.cssSelector("input.gLFyf.gsfi")).sendKeys("Selenium");; Thread.sleep(3000); driver.close(); //driver.quit(); } System.out.println("Completed 1 iteration"); } driver.switchTo().window(parent); Thread.sleep(3000); driver.close(); } } In firefox browser, it got executed till this line System.out.println("Before statements"); and generated this error Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: *[name='q'] For documentation on this error, please visit: seleniumhq.org/exceptions/no_such_element.html
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Hi Vaseem, its strange behavior, can you debug your code kzfaq.info/get/bejne/qL6ImKuX28jIlKM.html
@rohitranjan7322
@rohitranjan7322 5 жыл бұрын
sir your volume is very low.. please do something for it
@Mukeshotwani
@Mukeshotwani 5 жыл бұрын
Hi Rohit in recent videos I have improved sound quality.
@AlexWLychack
@AlexWLychack 6 жыл бұрын
Hey nice! Can you share your code, please?
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
Hi Alex I have code posted on my blog please have a look learn-automation.com/handle-multiple-windows-in-selenium-webdriver/
@anujamahajan7390
@anujamahajan7390 6 жыл бұрын
video is really good bt there is so Audio disturbance
@MrAmarSindol
@MrAmarSindol 6 жыл бұрын
sir, audio disturbance is too high, ur volume is too low, pls do something, ur hardwork is going waste
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
Hi Amar, I will try to fix soon
@saxenahimanshu6584
@saxenahimanshu6584 3 жыл бұрын
Everything is fine but Scenario: when the multiple windows are already open, then that "Set allwindows " can't count the windows numbers.
@SS-ug1qy
@SS-ug1qy 4 жыл бұрын
I am so happy supper annoying pop-up days are over. Yes, u see some here and there but not like before where every page u land has millions of pop-ups
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Welcome mate
@swadhikarc7858
@swadhikarc7858 7 жыл бұрын
Excellent video. In same way Python 2.7 I could do as below: line 5: its double underscore name. from selenium import webdriver from time import sleep if __name__ == '__main__': driver = webdriver.Chrome() driver.get('www.naukri.com/') windows = driver.window_handles parent = driver.current_window_handle # Close pop ups one by one ;) for window in windows: if window == parent: '''Ignore parent window''' continue driver.switch_to.window(window) print 'Gonna close window: {}...'.format(driver.title) sleep(1) driver.close() # Switch back driver.switch_to.window(parent) print 'Gonna close window: {}...'.format((driver.title.split(' - '))[-1]) sleep(5) driver.quit()
@amitdhanke4013
@amitdhanke4013 7 жыл бұрын
videos seems not in sequencing manner
@Mukeshotwani
@Mukeshotwani 7 жыл бұрын
Hi Amit, Follow video in below manner learn-automation.com/selenium-webdriver-tutorial-for-beginners/ learn-automation.com/advance-selenium-webdriver-tutorials/
@anushachalana5008
@anushachalana5008 7 жыл бұрын
Hi Mukesh, I have sent you one email regarding my doubt. Hope you get time to check that. Thanks
@ssk7690
@ssk7690 3 жыл бұрын
Bhagwan hai bhai tum
@Mukeshotwani
@Mukeshotwani 3 жыл бұрын
Bap re.
@ashish_yadav542
@ashish_yadav542 5 жыл бұрын
Audio very bad. Content good.
@Mukeshotwani
@Mukeshotwani 5 жыл бұрын
Hi, Ashish Yes I agree that in this video Audio was not good. I have created another video on the same. Please refer post and video for the same learn-automation.com/handle-multiple-windows-in-selenium-webdriver/
How to Handle BootStrap Login or Popup window in Selenium Webdriver
11:12
How to execute failed test cases in Selenium webdriver
17:09
Mukesh otwani
Рет қаралды 96 М.
IQ Level: 10000
00:10
Younes Zarou
Рет қаралды 11 МЛН
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 76 МЛН
What are GetWindowHandle and GetWindowHandles in Selenium? | Selenium Basics
12:42
Selenium WebDriver Tutorial #25 - How to Handle Multiple Windows in Selenium
20:29
Software Testing Mentor
Рет қаралды 54 М.
Page Object Model in Selenium Webdriver Step by Step Guide
31:21
Mukesh otwani
Рет қаралды 466 М.
How to Implement TestNG listeners in Selenium Webdriver
24:22
Mukesh otwani
Рет қаралды 152 М.
Handle Dynamic Google Search Using Dynamic XPath - WebDriver Session - 15
21:51
Naveen AutomationLabs
Рет қаралды 164 М.
How to Handle Multiple Windows in Selenium WebDriver
22:46
H Y R Tutorials
Рет қаралды 84 М.
How to Handle Frames in Selenium WebDriver
21:20
H Y R Tutorials
Рет қаралды 57 М.
Switch to a specific window out of 100 windows and validate it in #Selenium
13:17
Taking ScreenShot ONLY for Failed Tests in Selenium using TestNG Listener
32:12
Naveen AutomationLabs
Рет қаралды 116 М.