Thank you so much Naveen i really cant express happiness ..i am just asked every person but i dont get answer like you from any1 ...Really this concept is very very useful..bcoz 80% of people dnt know how to do bcoz we always depend upon select class..
For the already selected options, we can't use isSelected() method. Because this method always returns false. So we have to use the li-class which changes the class name to "active" when the checkbox is selected. So we can select all the checkboxes without unselecting the already selected ones by using below logic. for (int i = 0; i < bsOptions.size(); i++) { if ((bsOptions.get(i).getAttribute("class").equalsIgnoreCase("active"))) { System.out.println(bsOptions.get(i).getText()); Thread.sleep(1000); } else bsOptions.get(i).click(); }
As mentioned by madhu : - we have to get the list of elements as below ( i.e. till the li class) List elements = driver.findElements(By.xpath("//ul[contains(@class,'multiselect')]//li")); for (WebElement ele : elements) { System.out.println(ele.getAttribute("class").equalsIgnoreCase("active")); if(ele.getAttribute("class").equalsIgnoreCase("active")) { System.out.println(ele.getText()); } else { ele.click(); } }
@Navin_AutomationLabs thanks, but i have one diffrent scenario. that is dropdown within dropdown. i.e. main tap is 'Financial' then it has three dropdown menu, then that each have other 4 dropdown. how can it be handle
Hi, Naveen your videos are very good, in this video I've doubt i.e once I clicked on the dropdown button I got 14 options as you said. And I want to select Angular so here I can use Dynamic XPath right i.e selecting the checkbox based on Angular element na .. here I'll inspect the independent element angular and dependent element checkbox... using XPath as ....... //label[text()=' Angular']/../../..//input[@value='Angular']
hi sir am following your channel for my preparation it is excellent and i got so much from your channel...can u plz guide me is this info is enough for 3 yrs exp candidates where i wanted to try my job search on 3 yrs experience.. prevoiusly i wrked in non-it sector will u guide me i hope ...👍👍👍
Hi @naveen, I have a doubt why cannot we directly do the click operation rather than getting all the webelements of the bootstrap drop down and adding the for loop to find the text and then click, I understand that in dynamic web table we need to do this but why it is needed here also
That was really helpful.... Can you please make one tutorial is video for Jmeter 5.0 also...? Please because you have got awesome ability to explain.. I love ❤ the way you elaborate something. Thanks in advance.
Hi Navin, Thank you for the Bootstrap dropdown. It helped, but i have a dropdown which scrolls down, and using your method i was only able to select visible items in the dropdown, it is not scrolling down to find an element, used javascript query to scrollTo view, but did not scroll, can you help with this?
Hi Naveen I have same scenario where bootstrap dropdown having only "div" than nothing else. i have inspected on dropdown but found only div-class so unable to select dropdown items Could you please tell me how to handle such kind of dropdowns having only div class
Hello Naveen- I have the same scenario where I need to select multiple options from the dropdrown but when I click on the dropdrown and try to find the xpath of the elements in the dropdown, it does not show the xpath of the elements. The ul tag for me is hidden and I got it after i pressed F12 in the UI. Its very difficult for me to capture the xpath of the dropdown elements as when i just come out of the dropdown list the ul gets hidden in html code
Can't I write //ul[contains(@class,'multiselect-container')]//li//a//label[contains(text(),'Angular')] directly to select the element and perform click operation instead getting list of label then selecting that element and performing click operation?
If you want directly to click You can use //label[contains(text(),'Angular')] , but if your requirement is to validate all elements is thart dropDown you need to follow as Naveen did in video and store elements in List.
@Raghavi Br I hope you have got the code for span class but below code worked for me where there is div and span tag included... driver.findElement(By.xpath("//div[contains(@class,'selected-dial-code')]")).click();
List list = driver.findElements (By.xpath("//div[contains(@class,'flag-container')]//ul//li//span[contains(@class,'dial-code')]"));
Hiii guy's anyone recently faced interview for 3+experience guys. Which type questions you have faced at the time of interview pls pls guy's send me... Useful for everyone
Hello Naveen, what if i need to select multiple check boxes not all in the drop down and also its very difficult for me to capture the xpath of the dropdown elements as when i just come out of the dropdown list the ul gets hidden in html code
I use this customized xpath, List list = driver.findElements(By.xpath("//div[@class='dropdown show']//child::div")); System.out.println(list.size()); for(int i=0; i
Thank you so much Naveen i really cant express happiness ..i am just asked every person but i dont get answer like you from any1 ...Really this concept is very very useful..bcoz 80% of people dnt know how to do bcoz we always depend upon select class..
Thank you very much Naveen to explain this topic in a smart and easy way. Keep it up Naveen😊
Hi Naveen, videos which your posting is very helpful and am referring your video to practice and expertise automation....really helpful
For the already selected options, we can't use isSelected() method. Because this method always returns false. So we have to use the li-class which changes the class name to "active" when the checkbox is selected. So we can select all the checkboxes without unselecting the already selected ones by using below logic.
for (int i = 0; i < bsOptions.size(); i++) {
if ((bsOptions.get(i).getAttribute("class").equalsIgnoreCase("active"))) {
System.out.println(bsOptions.get(i).getText());
Thread.sleep(1000);
} else
bsOptions.get(i).click();
}
awesome bro !
As mentioned by madhu : - we have to get the list of elements as below ( i.e. till the li class)
List elements = driver.findElements(By.xpath("//ul[contains(@class,'multiselect')]//li"));
for (WebElement ele : elements) {
System.out.println(ele.getAttribute("class").equalsIgnoreCase("active"));
if(ele.getAttribute("class").equalsIgnoreCase("active"))
{
System.out.println(ele.getText());
}
else {
ele.click();
}
}
Hello Sir, i was looking for a solution for this issue, thanks a lot for the comment
Very nice explanation..which is in detail..i just subscribed your channel though its old its very useful now..
Great Thanks Naveen, this video helped me a lot, I paid attention you always sharing solution for most tricky cases. Again Thanks a lot .
Awesome explanation👌👌... Thank you 💐💐
You are a damn hero!
nice lecture plz keep uploading
💌 excellent video
Thank you naveen. it helped and worked great!
Glad it helped :)
Nice tutorial. Please make another tutorial to handle angular js dropdown.
@Navin_AutomationLabs thanks, but i have one diffrent scenario. that is dropdown within dropdown. i.e. main tap is 'Financial' then it has three dropdown menu, then that each have other 4 dropdown. how can it be handle
Use this method for calendar. It work
thanks ... can you also share me how to work in roboframe work /pycharm only-- i dont use java framework??if you have already uploaded pls share
Hi naveen can you tell me how to validate which options from. Dropdown are highlighted by default (bootstrap dropdown)
Good
Hi, Naveen your videos are very good,
in this video I've doubt i.e once I clicked on the dropdown button I got 14 options as you said. And I want to select Angular so here I can use
Dynamic XPath right i.e selecting the checkbox based on Angular element na .. here I'll inspect the independent element angular and dependent element checkbox... using XPath as ....... //label[text()=' Angular']/../../..//input[@value='Angular']
thanks for share, this video was very useful!
Hi Naveen.. What if we have select tag under the div tag. Its not working if I use select class over there. Can I use your method for bootstrap??
hi sir am following your channel for my preparation it is excellent and i got so much from your channel...can u plz guide me is this info is enough for 3 yrs exp candidates where i wanted to try my job search on 3 yrs experience.. prevoiusly i wrked in non-it sector will u guide me i hope ...👍👍👍
Hi @naveen, I have a doubt why cannot we directly do the click operation rather than getting all the webelements of the bootstrap drop down and adding the for loop to find the text and then click, I understand that in dynamic web table we need to do this but why it is needed here also
Thanks sir
Hi Naveen, How to automate the Material UI dropdown?
That was really helpful....
Can you please make one tutorial is video for Jmeter 5.0 also...?
Please because you have got awesome ability to explain.. I love ❤ the way you elaborate something.
Thanks in advance.
Hi Navin, Thank you for the Bootstrap dropdown. It helped, but i have a dropdown which scrolls down, and using your method i was only able to select visible items in the dropdown, it is not scrolling down to find an element, used javascript query to scrollTo view, but did not scroll, can you help with this?
Bro can you tell me how can I select random value on such a drop down
Thanks a ton...
Hi Naveen
I have same scenario where bootstrap dropdown having only "div" than nothing else. i have inspected on dropdown but found only div-class so unable to select dropdown items
Could you please tell me how to handle such kind of dropdowns having only div class
Hello Naveen- I have the same scenario where I need to select multiple options from the dropdrown but when I click on the dropdrown and try to find the xpath of the elements in the dropdown, it does not show the xpath of the elements. The ul tag for me is hidden and I got it after i pressed F12 in the UI. Its very difficult for me to capture the xpath of the dropdown elements as when i just come out of the dropdown list the ul gets hidden in html code
Can't I write //ul[contains(@class,'multiselect-container')]//li//a//label[contains(text(),'Angular')] directly to select the element and perform click operation instead getting list of label then selecting that element and performing click operation?
I also have the same doubt. Have you checked the xpath?
Yes you can use the same as well
If you want directly to click You can use //label[contains(text(),'Angular')] , but if your requirement is to validate all elements is thart dropDown you need to follow as Naveen did in video and store elements in List.
Hi Navin, Can we use the same logic for Span class as well ? Please reply
@Raghavi Br I hope you have got the code for span class but below code worked for me where there is div and span tag included...
driver.findElement(By.xpath("//div[contains(@class,'selected-dial-code')]")).click();
List list = driver.findElements
(By.xpath("//div[contains(@class,'flag-container')]//ul//li//span[contains(@class,'dial-code')]"));
System.out.println(list.size());
for (int i=0;i
Hello Naveen Can u share the link which u used
I am facing some issue in selecting value in bootstrap drop down , i cant even see the drop down values in HTML code . Please help me with this .
Could you please how to edit drop-down values
Hiii guy's anyone recently faced interview for 3+experience guys. Which type questions you have faced at the time of interview pls pls guy's send me... Useful for everyone
Thank you !!
Hello Naveen, what if i need to select multiple check boxes not all in the drop down and also its very difficult for me to capture the xpath of the dropdown elements as when i just come out of the dropdown list the ul gets hidden in html code
You can use the or || operator to select multiple values in the if condition.
How to write the code when select value which try to find out by index???
Select selectElement=new Select();
selectElement.selectByValue("value" ); here value is attribute of the options tag
You can past index as a argument to your method and while you are looping just do :--> if(i==arg){ List.get(i).click(); }
😊🙏
I use this customized xpath, List list = driver.findElements(By.xpath("//div[@class='dropdown show']//child::div"));
System.out.println(list.size());
for(int i=0; i
you must need to show some different websites