How to Handle Multiple Windows or Tabs in Selenium Webdriver

  Рет қаралды 171,699

Mukesh otwani

Mukesh otwani

Күн бұрын

Пікірлер: 212
@alexandrutudosan3319
@alexandrutudosan3319 4 жыл бұрын
best video on window handler!!
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
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!
@AnirudhGarg1123
@AnirudhGarg1123 7 жыл бұрын
Please do something for audio disturbance. Content is great.
@maroofraktim293
@maroofraktim293 9 ай бұрын
Indeed, this is the best video on window handling. Keep up the good work.
@Mukeshotwani
@Mukeshotwani 8 ай бұрын
Thank you so much
@darkflame4441
@darkflame4441 4 жыл бұрын
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 4 жыл бұрын
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.
@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
@praveenjaldawar2652
@praveenjaldawar2652 4 жыл бұрын
Hi Mukesh, Superb explaination of handling popups with debugging..Thank you very much.
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Thanks Praveen :)
@sanjupole1491
@sanjupole1491 5 жыл бұрын
Why do we need to convert set into arraylist? Please explain.
@user-durga_sankar
@user-durga_sankar Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@Mukeshotwani Thank You so much.
@manjunathah9025
@manjunathah9025 4 жыл бұрын
Mukesh, where are you setting the driver path in your code?
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Hi Manjunatha, here is the video for same kzbin.info/www/bejne/qYXHiZiqqdJkr5o
@manjunathah9025
@manjunathah9025 4 жыл бұрын
@@Mukeshotwani appreciate your reply. Got the answer. Even you talked about using DriverManager also. Helpful. 👍
@manjunathah9025
@manjunathah9025 4 жыл бұрын
@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 4 жыл бұрын
please share your code
@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.
@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.
@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.
@saurabhshirsath1755
@saurabhshirsath1755 2 жыл бұрын
Thanks for this wonderful explanation.
@Mukeshotwani
@Mukeshotwani 2 жыл бұрын
Glad it was helpful! Saurabh
@himanis6821
@himanis6821 4 жыл бұрын
Hello Sir, do we use the same code for switching to new tab and new window after click of any link ?
@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.
@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
@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.
@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.
@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
@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.
@Ashirbadratha
@Ashirbadratha 6 жыл бұрын
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 6 жыл бұрын
Hi Abhisek as I mentioned in the video that once you get all windows as List then you can traverse in any direction.
@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??
@sasmitamandal820
@sasmitamandal820 4 жыл бұрын
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 4 жыл бұрын
Hi Sasmita, for IE you might have to change registry value.
@rajeshbe2234
@rajeshbe2234 6 жыл бұрын
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?
@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.
@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.
@malikah7145
@malikah7145 3 жыл бұрын
how is the start session on same window ?
@Mukeshotwani
@Mukeshotwani 3 жыл бұрын
Hi Malikah, if link opens in same window then no need to handle.
@GagandeepKaur-jh6tw
@GagandeepKaur-jh6tw 4 жыл бұрын
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?
@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
@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.
@thems444
@thems444 2 жыл бұрын
Please make on the Selenium in JavaScript also.
@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.
@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
@rameshbangaru2710
@rameshbangaru2710 5 жыл бұрын
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.
@sankalpboradkar8682
@sankalpboradkar8682 6 жыл бұрын
Hello Can you please tell how to open multiple tabs in the same window
@jatinqa4020
@jatinqa4020 2 жыл бұрын
Hi mukesh sir, I wanna know that how to pass data from one page to another
@Mukeshotwani
@Mukeshotwani 2 жыл бұрын
Hi Jatin, you can return the values from methods and you can accept in next page.
@KumarSatyajeet
@KumarSatyajeet 6 жыл бұрын
If in the child window, we will get another window then how to handle this sub-child window?
@krishnavamsi9795
@krishnavamsi9795 4 жыл бұрын
Feel like best of all explanations loved ot sir ty
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
So nice of you Krishna thank you.
@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" ??
@animolshameer2355
@animolshameer2355 5 жыл бұрын
Thanks for your detailed description and it was really useful!!!
@Mukeshotwani
@Mukeshotwani 5 жыл бұрын
Thanks Animol
@Rahulkumar-su5jd
@Rahulkumar-su5jd 5 жыл бұрын
@@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
@sangeethkumar9190
@sangeethkumar9190 3 жыл бұрын
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
@shanmugasrinivas8004
@shanmugasrinivas8004 2 жыл бұрын
Very helpful for me, Thank you
@Mukeshotwani
@Mukeshotwani 2 жыл бұрын
Glad it was helpful! Tahnks Shanmuga
@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 4 жыл бұрын
@@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
@dhru2512
@dhru2512 7 жыл бұрын
NIce work and explanation brother Keep up the good work and i am really looking forward to the upcoming new videos.
@Mukeshotwani
@Mukeshotwani 7 жыл бұрын
Hi Pathak ji, stay tunned I have planned multiple videos in 2018..
@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. :)
@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/
@sangamsood5651
@sangamsood5651 5 жыл бұрын
i want to select 2nd value of index for multiple dropdown in one class
@rajeshbe2234
@rajeshbe2234 6 жыл бұрын
Sir how handle multi windows at a time b/w switch them with the single loop ?
@pujithaa9973
@pujithaa9973 5 жыл бұрын
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 5 жыл бұрын
Hi Pujitha, you can store them as list as I explained in below and then you can use index for switching.
@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?
@Bujji28243
@Bujji28243 7 жыл бұрын
it a great video it's work good but can we handle windows through title names????
@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 5 жыл бұрын
​@@Mukeshotwani please make a video on how to switch from parent to child then again a new child window
@saakshib7490
@saakshib7490 6 жыл бұрын
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 6 жыл бұрын
Sure Saakshi noted your points. I will cover for basic for loop and enhanced for loop as well.
@saakshib7490
@saakshib7490 6 жыл бұрын
@@Mukeshotwani Thank you sir :)
@jitendrasheliya2301
@jitendrasheliya2301 6 жыл бұрын
Very Very Useful, thank you Mukesh.
@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 kzbin.info/www/bejne/eWmqpoSMnqt3abs
@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,!
@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 !
@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.
@onlyuser8374
@onlyuser8374 3 жыл бұрын
how to automate the existing window or tab ,without opening new browser or tab
@deekshithb5459
@deekshithb5459 6 жыл бұрын
master , i have a doubt here why ur converting SET into LIST what is the reason.........
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
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 - kzbin.info/www/bejne/hXfNinRmltWMfbs Set in Java- kzbin.info/www/bejne/mXynZpeqj56gb7c
@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)
@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.
@thebgagabati
@thebgagabati 4 жыл бұрын
Thanks. This is working for me now.
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Great
@aayushpatel3360
@aayushpatel3360 4 жыл бұрын
awesome sir, really much helpful
@ramankumar1487
@ramankumar1487 5 жыл бұрын
please make a video on how to switch from parent to child then again a new child window
@kirtibanga8292
@kirtibanga8292 3 жыл бұрын
Thank you for wonderful video. This is very informative.
@venkateshgampa619
@venkateshgampa619 7 жыл бұрын
Hi your videos are very helpful thank you
@Mukeshotwani
@Mukeshotwani 7 жыл бұрын
Most welcome Mate :) Keep visiting.
@dineshkumaar2117
@dineshkumaar2117 4 жыл бұрын
Very Good explanation , but lot of audio disturbance
@divyar5116
@divyar5116 6 жыл бұрын
Thanku very much. Nice explanation.
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
Thanks Divya :)
@juliagutorova5807
@juliagutorova5807 3 жыл бұрын
Thanks, really good explanation!
@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...
@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.
@RuchiSingh-jo7dc
@RuchiSingh-jo7dc 4 жыл бұрын
If I want to scroll child page instead of parents then how it will be possible?
@YashPratap009
@YashPratap009 7 жыл бұрын
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 7 жыл бұрын
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.
@akashsinha4583
@akashsinha4583 7 жыл бұрын
sir its not working its opening the tab and not navigate to that window
@Mukeshotwani
@Mukeshotwani 7 жыл бұрын
Hi Akash, may be some code issue. Please send code to mukeshotwani@learn-automation.com
@MrAmarSindol
@MrAmarSindol 7 жыл бұрын
sir, audio disturbance is too high, ur volume is too low, pls do something, ur hardwork is going waste
@Mukeshotwani
@Mukeshotwani 7 жыл бұрын
Hi Amar, I will try to fix soon
@mohitgoel9596
@mohitgoel9596 7 жыл бұрын
please make an tutorial in findbys and findAll
@theriderpanda
@theriderpanda 4 жыл бұрын
Hi guys, if your page doesn't have clickable links then try this code to open a new tab, and then you could use the logic explained in the video to handle tabs/windows. String url="example.com"; JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("window.open(arguments[0])", url);
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Hey Pavan thank for the code and your input.
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
I am wondering if link is not clickable then as per user perspective he wont be access the link.
@theriderpanda
@theriderpanda 4 жыл бұрын
@@Mukeshotwani Hi Mukesh, In my use case, I need to open a new tab and access some email, and switch back to the parent window to continue the testing on the main page. So I thought people who are working on such use cases, this code might be useful.
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
@@theriderpanda Yes definitely it would help others and yes now I can understand your scenario too.
@arunragavan442
@arunragavan442 4 жыл бұрын
tq so much i searching everywhere but u only give me solution
@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"); } } } } }
@dipalisanas3914
@dipalisanas3914 4 жыл бұрын
A lot of audio disturbance, but helpful session thank you.
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Thanks Dipali I am working on the audio part... 🙏
@anujamahajan7390
@anujamahajan7390 6 жыл бұрын
video is really good bt there is so Audio disturbance
@SS-ug1qy
@SS-ug1qy 5 жыл бұрын
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 5 жыл бұрын
Welcome mate
@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.
@nancybhardwaj3895
@nancybhardwaj3895 3 жыл бұрын
Thank you Mukesh
@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/
@seenukaniappan8882
@seenukaniappan8882 7 жыл бұрын
Keep Rocking !
@Mukeshotwani
@Mukeshotwani 7 жыл бұрын
+Seenu Kaniappan 😀
@veera.akasapu
@veera.akasapu 3 жыл бұрын
Thank you
@Mukeshotwani
@Mukeshotwani 3 жыл бұрын
You're welcome Veera
@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
@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 kzbin.info/www/bejne/povHfqaCgKadqZY
@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 kzbin.info/www/bejne/qIm7lnucq8eXmtE
@dabbark
@dabbark 6 жыл бұрын
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()); } }
@sutapapramanick4692
@sutapapramanick4692 4 жыл бұрын
best video
@Mukeshotwani
@Mukeshotwani 4 жыл бұрын
Thanks Sutapa
@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
@991tanmay
@991tanmay 3 жыл бұрын
Kindly use a better mic, the content is really good but the audio disturbance is just horrible :(
@akankshachowdary5738
@akankshachowdary5738 6 жыл бұрын
Please y don't u maintain ur audio.... It's very disturbing
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
Hi Akansha few videos has some voice issue. Can you check voice in new videos?
@ashish_yadav542
@ashish_yadav542 6 жыл бұрын
Audio very bad. Content good.
@Mukeshotwani
@Mukeshotwani 6 жыл бұрын
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/
@manishtembhare4
@manishtembhare4 2 жыл бұрын
Bhai collections aur isme bhi bahut kharkharahat hai video ke beech mein, kaan ke parde hil jaate hain aur words miss ho ja rahe hain .... Baaki automation tester toh aap hi bana ke chhodoge. ✌
@Mukeshotwani
@Mukeshotwani 2 жыл бұрын
Thank you Manish bhai.. Collection ka alag Maza hai har jagah Selenium me b Rest Assured b.
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
Рет қаралды 97 М.
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
Dynamic XPath in Selenium  using Different Approaches
28:12
Mukesh otwani
Рет қаралды 301 М.
Selenium WebDriver Tutorial #25 - How to Handle Multiple Windows in Selenium
20:29
Software Testing Mentor
Рет қаралды 57 М.
How to Implement TestNG listeners in Selenium Webdriver
24:22
Mukesh otwani
Рет қаралды 153 М.
What are GetWindowHandle and GetWindowHandles in Selenium? | Selenium Basics
12:42
How to Handle Frames in Selenium WebDriver - Session 4a
20:47
Naveen AutomationLabs
Рет қаралды 178 М.
How to Handle Frames in Selenium WebDriver
21:20
H Y R Tutorials
Рет қаралды 64 М.
How to Handle Frames in Selenium Webdriver
27:03
Mukesh otwani
Рет қаралды 114 М.
How to Handle Alert in Selenium Webdriver
17:32
Mukesh otwani
Рет қаралды 63 М.
Карина Кросс #shorts
0:16
Dolly and Friends Shorts Cartoons
Рет қаралды 361 М.
Satisfying Vend 😦 Ep.5 #shorts #satisfying #vendingmachine
0:23
TYE Arcade
Рет қаралды 17 МЛН
Robot 🤖 cleaning 🧹
0:57
Bunnal 𝚃𝚎𝚌𝚑
Рет қаралды 4,7 МЛН
Массаж головы пранк🤣
0:55
Kirya Kolesnikov
Рет қаралды 5 МЛН