The share link has been copied to clipboard
How To Handle Dynamic Dropdown In Selenium Webdriver
944 views · Jun 23, 2022
Visit Channel:teachyourselftestautomation.com
How To Handle Dynamic Dropdown in Selenium Webdriver http://teachyourselftestautomation.com
Selenium Certification Training: http://bitly.com/2PA8HCA

Hello and welcome to Day 17 - How To Handle Dynamic Dropdown in Selenium Webdriver

Today we are teaching ourselves How To Handle Dynamic Dropdown Selenium Webdriver

Practice site - https://www.spicejet.com/

I have had to re-work day 17 How To Handle Dynamic Dropdown Selenium Webdriver because i was not too pleased with the example i used last time round, sorry about that

I have been away for a while to take care of some family business but i'm back to be consistent, persistent, in achieving what i set out to do wit this project which is teach myself test automation and setting up a framework from scratch 

Our example website today is: https://www.spicejet.com/

First question you should ask yourself is - what is a dynamic drop down?

User actions determine the way the drop down behaves/react? 

In our example here were we are selecting a city to fly from and to, only when you select a city you wan to fly from do you have city selection options in the to drop down  

If you don't make any selection in the from drop down the to drop down field remains empty hope this makes sense and if it doesn't place watch the video that goes with this description
here: https://youtu.be/e-nRB20DOLc

It's straight forward to select the city to fly from buy using xpath with value as our attribute for our locator strategy 

With the selection of the city from the to field it's a bit tricky

Basically the way the developers have developed this elements is in a way were we have same cities in the drop down in the 'from' and 'to' field as well as identical HTML code for both sets of 
cities in the fields too

So when you come to select a city option in the to field as selenium scans the web page left to right it will locate the first city option but it will be in the from field instead of the to field hence your script will fail as element not visible

To get round this issue you use index which is telling selenium to make the second selection it comes across not the first so now selenium will select second city option from the to field

Success!!!

Please see video for live examples on the above https://youtu.be/e-nRB20DOLc

Don't forget to subscribe if you found this video helpful, support the channel and SUBSCRIBE

Many Thanks 

Kevin Owasu Itoe

How To Handle Dynamic Dropdown Selenium Webdriver http://teachyourselftestautomation.com
--------------------------------------------------------------------------------------------------------
#testautomation #teachyourselftestautomation #selenium #webdriver #java
--------------------------------------------------------------------------------------------------------
Follow me @
Facebook: https://www.facebook.com/kevin.itoe.50
Google+: https://plus.google.com/u/0/103559195030509162975
Pinterest: https://www.pinterest.co.uk/owasuik/
My Blog: http://teachyourselftestautomation.com/
My YouTube Channel: https://www.youtube.com/channel/UCbmeSbAPc19BjqD-08RqHyw?view_as=subscriber
--------------------------------------------------------------------------------------------------------
My Videos: 
https://youtu.be/OFxr9RmijTY
https://youtu.be/6lHi3kGDh4A
https://youtu.be/6jx2YMNUNt0
https://youtu.be/yoffcUDb_10
https://youtu.be/mwn0IALm1-M
https://youtu.be/ZdY6gXlkLc0
https://youtu.be/nfYx3MhScc0
https://youtu.be/eY07MPQFZws
https://youtu.be/FeTOwEVshsQ
https://youtu.be/0k_lC7hmCNQ
https://youtu.be/tl-p-fi5otM
https://youtu.be/auB5UV67igQ
https://youtu.be/QuHXZneiJq0
https://youtu.be/-ROkNuWbHR8
https://youtu.be/-jwMgQu0TzQ
https://youtu.be/mjvGnoxf3Ek
https://youtu.be/q5nbQBKwG30
https://youtu.be/r1EvmjIR1Gs
https://youtu.be/dAepopoWiUc
https://youtu.be/pvQOThg2w-0
https://youtu.be/RLHIPQnsxqg
https://youtu.be/kOwBWZzEudE
https://youtu.be/wcihef1UVTI
https://youtu.be/e-nRB20DOLc
-------------------------------------------------------------------------------------------------------
What Wikipedia says about selenium: https://en.wikipedia.org/wiki/Selenium_(software)
What Wikipedia says about test automation: https://en.wikipedia.org/wiki/Test_automation
Show More

Comments

loading text loading
loading text loading
loading text
loading text loading
loading text
loading text loading
loading text
loading text loading
loading text