Issue
HTML:
<div class="ui-lib-sidebar-grid__content"><div class="ui-lib-margin-b_md ui-lib-margin-t_md totalResultsText"><p class="totalResultsText">Showing 1-10 of 316 results</p></div><div class="" style=""><div class="ui-lib-category-list ui-lib-category-list-dummy"><div class="ui-lib-category-list-item"><div class="ui-lib-category-list-item__content"><div class="ui-lib-category-list-item__content-header"><div class="ui-lib-category-list-item-type"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMid slice" data-key="" class="ui-lib-category-list-item-type__icon ui-lib-category-list-item-type__icon_service ui-lib-icon" width="24" height="24" viewBox="0 0 24 24"><title></title><circle cx="12" cy="12" r="12" fill-rule="evenodd"></circle></svg><span class="ui-lib-category-list-item-type__label">Service</span></div></div><a class="ui-lib-link ui-lib-link_default" target="_self" aria-label="Request for Collection and Transfer of Green Waste from Residential Areas" rel="noopener noreferrer" href="https://www.tamm.abudhabi/en/aspects-of-life/environmentagriculture/Waste-Management/WasteCollectionandTransportation/RequestforCollectionandTransferofGreenWastefromResidentialAreas"><h4 class="ui-lib-link__heading ui-lib-bold">Request for Collection and Transfer of Green Waste from Residential Areas</h4></a><div class="ui-lib-category-list-item__description">Through this service, you can request the collection and transfer of green wastes from residential areas.</div><div class="ui-lib-category-list-item__tags"><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_grey ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Abu Dhabi Waste Management Center</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Expat</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Visitor</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Emirati</span></div></div></div></div><div class="ui-lib-category-list-item"><div class="ui-lib-category-list-item__content"><div class="ui-lib-category-list-item__content-header"><div class="ui-lib-category-list-item-type"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMid slice" data-key="" class="ui-lib-category-list-item-type__icon ui-lib-category-list-item-type__icon_service ui-lib-icon" width="24" height="24" viewBox="0 0 24 24"><title></title><circle cx="12" cy="12" r="12" fill-rule="evenodd"></circle></svg><span class="ui-lib-category-list-item-type__label">Service</span></div></div><a class="ui-lib-link ui-lib-link_default" target="_self" aria-label="Request for Collection and Transfer of Large-Scale Wastes from Residential Areas" rel="noopener noreferrer" href="https://www.tamm.abudhabi/en/aspects-of-life/environmentagriculture/Waste-Management/WasteCollectionandTransportation/RequestforCollectionandTransferofLargeScaleWastesfromResidentialAreas"><h4 class="ui-lib-link__heading ui-lib-bold">Request for Collection and Transfer of Large-Scale Wastes from Residential Areas</h4></a><div class="ui-lib-category-list-item__description">Through this service, you can request the collection and transfer of wastes in large amounts from residential areas.</div><div class="ui-lib-category-list-item__tags"><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_grey ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Abu Dhabi Waste Management Center</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Expat</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Visitor</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Emirati</span></div></div></div></div><div class="ui-lib-category-list-item"><div class="ui-lib-category-list-item__content"><div class="ui-lib-category-list-item__content-header"><div class="ui-lib-category-list-item-type"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMid slice" data-key="" class="ui-lib-category-list-item-type__icon ui-lib-category-list-item-type__icon_service ui-lib-icon" width="24" height="24" viewBox="0 0 24 24"><title></title><circle cx="12" cy="12" r="12" fill-rule="evenodd"></circle></svg><span class="ui-lib-category-list-item-type__label">Service</span></div></div><a class="ui-lib-link ui-lib-link_default" target="_self" aria-label="Request for Licencing a Private Notary Office" rel="noopener noreferrer" href="https://www.tamm.abudhabi/en/aspects-of-life/lawregulations/notarypublic/NotaryPublicLicensing/RequestforLicencingaPrivateNotaryOffice"><h4 class="ui-lib-link__heading ui-lib-bold">Request for Licencing a Private Notary Office</h4></a><div class="ui-lib-category-list-item__description">Apply for licencing a private notary office</div><div class="ui-lib-category-list-item__tags"><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_grey ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Abu Dhabi Judicial Department</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Business</span></div></div></div></div><div class="ui-lib-category-list-item"><div class="ui-lib-category-list-item__content"><div class="ui-lib-category-list-item__content-header"><div class="ui-lib-category-list-item-type"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMid slice" data-key="" class="ui-lib-category-list-item-type__icon ui-lib-category-list-item-type__icon_service ui-lib-icon" width="24" height="24" viewBox="0 0 24 24"><title></title><circle cx="12" cy="12" r="12" fill-rule="evenodd"></circle></svg><span class="ui-lib-category-list-item-type__label">Service</span></div></div><a class="ui-lib-link ui-lib-link_default" target="_self" aria-label="Request for Transferring the Licence of a Private Notary from One Office to Another" rel="noopener noreferrer" href="https://www.tamm.abudhabi/en/aspects-of-life/lawregulations/notarypublic/NotaryPublicLicensing/requestfortransferringthelicenceofaprivatenotaryfromoneofficetoanother"><h4 class="ui-lib-link__heading ui-lib-bold">Request for Transferring the Licence of a Private Notary from One Office to Another</h4></a><div class="ui-lib-category-list-item__description">Apply for transferring the licence of a private notary from one office to another</div><div class="ui-lib-category-list-item__tags"><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_grey ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Abu Dhabi Judicial Department</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Business</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Emirati</span></div></div></div></div><div class="ui-lib-category-list-item"><div class="ui-lib-category-list-item__content"><div class="ui-lib-category-list-item__content-header"><div class="ui-lib-category-list-item-type"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMid slice" data-key="" class="ui-lib-category-list-item-type__icon ui-lib-category-list-item-type__icon_service ui-lib-icon" width="24" height="24" viewBox="0 0 24 24"><title></title><circle cx="12" cy="12" r="12" fill-rule="evenodd"></circle></svg><span class="ui-lib-category-list-item-type__label">Service</span></div></div><a class="ui-lib-link ui-lib-link_default" target="_self" aria-label="Request for Cancelling the Registration of a Private Notary Office" rel="noopener noreferrer" href="https://www.tamm.abudhabi/en/aspects-of-life/lawregulations/notarypublic/NotaryPublicLicensing/requestforcancellingtheregistrationofaprivatenotaryoffice"><h4 class="ui-lib-link__heading ui-lib-bold">Request for Cancelling the Registration of a Private Notary Office</h4></a><div class="ui-lib-category-list-item__description">Apply for cancelling the registration of a private notary office</div><div class="ui-lib-category-list-item__tags"><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_grey ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Abu Dhabi Judicial Department</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Business</span></div></div></div></div><div class="ui-lib-category-list-item"><div class="ui-lib-category-list-item__content"><div class="ui-lib-category-list-item__content-header"><div class="ui-lib-category-list-item-type"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMid slice" data-key="" class="ui-lib-category-list-item-type__icon ui-lib-category-list-item-type__icon_service ui-lib-icon" width="24" height="24" viewBox="0 0 24 24"><title></title><circle cx="12" cy="12" r="12" fill-rule="evenodd"></circle></svg><span class="ui-lib-category-list-item-type__label">Service</span></div></div><a class="ui-lib-link ui-lib-link_default" target="_self" aria-label="Request to Open a New Branch for a Private Notary Office" rel="noopener noreferrer" href="https://www.tamm.abudhabi/en/aspects-of-life/lawregulations/notarypublic/NotaryPublicLicensing/requestforopeninganewbranchofaprivatenotaryoffice"><h4 class="ui-lib-link__heading ui-lib-bold">Request to Open a New Branch for a Private Notary Office</h4></a><div class="ui-lib-category-list-item__description">Apply for opening a new branch of a private notary office</div><div class="ui-lib-category-list-item__tags"><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_grey ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Abu Dhabi Judicial Department</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Business</span></div></div></div></div><div class="ui-lib-category-list-item"><div class="ui-lib-category-list-item__content"><div class="ui-lib-category-list-item__content-header"><div class="ui-lib-category-list-item-type"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMid slice" data-key="" class="ui-lib-category-list-item-type__icon ui-lib-category-list-item-type__icon_service ui-lib-icon" width="24" height="24" viewBox="0 0 24 24"><title></title><circle cx="12" cy="12" r="12" fill-rule="evenodd"></circle></svg><span class="ui-lib-category-list-item-type__label">Service</span></div></div><a class="ui-lib-link ui-lib-link_default" target="_self" aria-label="Request for Renewal of a Private Notary Office Registration Card" rel="noopener noreferrer" href="https://www.tamm.abudhabi/en/aspects-of-life/lawregulations/notarypublic/NotaryPublicLicensing/requestforrenewalofaprivatenotaryofficeregistrationcard"><h4 class="ui-lib-link__heading ui-lib-bold">Request for Renewal of a Private Notary Office Registration Card</h4></a><div class="ui-lib-category-list-item__description">Apply for renewal of a private notary office registration card</div><div class="ui-lib-category-list-item__tags"><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_grey ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Abu Dhabi Judicial Department</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Business</span></div></div></div></div><div class="ui-lib-category-list-item"><div class="ui-lib-category-list-item__content"><div class="ui-lib-category-list-item__content-header"><div class="ui-lib-category-list-item-type"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMid slice" data-key="" class="ui-lib-category-list-item-type__icon ui-lib-category-list-item-type__icon_service ui-lib-icon" width="24" height="24" viewBox="0 0 24 24"><title></title><circle cx="12" cy="12" r="12" fill-rule="evenodd"></circle></svg><span class="ui-lib-category-list-item-type__label">Service</span></div></div><a class="ui-lib-link ui-lib-link_default" target="_self" aria-label="Request Nuisance Pest Control" rel="noopener noreferrer" href="https://www.tamm.abudhabi/en/aspects-of-life/environmentagriculture/Waste-Management/PublicHealthPestControl/RequestNuisancePestControl"><h4 class="ui-lib-link__heading ui-lib-bold">Request Nuisance Pest Control</h4></a><div class="ui-lib-category-list-item__description">Through this service, you can request nuisance pest control for ants, termites, lizards, German cockroaches, ticks, fleas and bed bugs.</div><div class="ui-lib-category-list-item__tags"><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_grey ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Abu Dhabi Waste Management Center</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Emirati</span></div></div></div></div><div class="ui-lib-category-list-item"><div class="ui-lib-category-list-item__content"><div class="ui-lib-category-list-item__content-header"><div class="ui-lib-category-list-item-type"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMid slice" data-key="" class="ui-lib-category-list-item-type__icon ui-lib-category-list-item-type__icon_service ui-lib-icon" width="24" height="24" viewBox="0 0 24 24"><title></title><circle cx="12" cy="12" r="12" fill-rule="evenodd"></circle></svg><span class="ui-lib-category-list-item-type__label">Service</span></div></div><a class="ui-lib-link ui-lib-link_default" target="_self" aria-label="Request Stray Animal Impounding" rel="noopener noreferrer" href="https://www.tamm.abudhabi/en/aspects-of-life/environmentagriculture/Waste-Management/PublicHealthPestControl/RequestStrayAnimalImpounding"><h4 class="ui-lib-link__heading ui-lib-bold">Request Stray Animal Impounding</h4></a><div class="ui-lib-category-list-item__description">Through this service, you can request and schedule impounding stray animals, such as camels, cows, cats, dogs, etc.</div><div class="ui-lib-category-list-item__tags"><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_grey ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Abu Dhabi Waste Management Center</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Expat</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Visitor</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Emirati</span></div></div></div></div><div class="ui-lib-category-list-item"><div class="ui-lib-category-list-item__content"><div class="ui-lib-category-list-item__content-header"><div class="ui-lib-category-list-item-type"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMid slice" data-key="" class="ui-lib-category-list-item-type__icon ui-lib-category-list-item-type__icon_service ui-lib-icon" width="24" height="24" viewBox="0 0 24 24"><title></title><circle cx="12" cy="12" r="12" fill-rule="evenodd"></circle></svg><span class="ui-lib-category-list-item-type__label">Service</span></div></div><a class="ui-lib-link ui-lib-link_default" target="_self" aria-label="Request Vector Pest Control Service" rel="noopener noreferrer" href="https://www.tamm.abudhabi/en/aspects-of-life/environmentagriculture/Waste-Management/PublicHealthPestControl/RequestVectorPestControlService"><h4 class="ui-lib-link__heading ui-lib-bold">Request Vector Pest Control Service</h4></a><div class="ui-lib-category-list-item__description">Through this service, you can request vector pest control of mosquitos, flies, rodents and American cockroaches.</div><div class="ui-lib-category-list-item__tags"><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_grey ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Abu Dhabi Waste Management Center</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Expat</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Visitor</span></div><div tabindex="0" role="button" class="ui-lib-tag ui-lib-tag_size-default ui-lib-tag_blue ui-lib-tag_hoverable ui-lib-tag_clickable"><span class="ui-lib-tag__text">Emirati</span></div></div></div></div></div></div><div class="ui-lib-margin-t_ ui-lib-margin-b_xl search-pagination" style=""><div class="ui-lib-pagination ui-lib-pagination_align-center"><div class="ui-lib-pagination__item ui-lib-pagination__item_page ui-lib-pagination__item_current" aria-label="" role="button" tabindex="0">1</div><div class="ui-lib-pagination__item ui-lib-pagination__item_page" aria-label="" role="button" tabindex="0">2</div><div class="ui-lib-pagination__item ui-lib-pagination__item_page" aria-label="" role="button" tabindex="0">3</div><div class="ui-lib-pagination__item ui-lib-pagination__item_page" aria-label="" role="button" tabindex="0">4</div><div class="ui-lib-pagination__item ui-lib-pagination__item_page" aria-label="" role="button" tabindex="0">5</div><div class="ui-lib-pagination__item ui-lib-pagination__item_dots" aria-label="Next 3 Pages" role="button" tabindex="0"><svg tabindex="0" version="1.1" xmlns="http://www.w3.org/2000/svg" data-key="" class="ui-lib-pagination__item-icon ui-lib-icon" width="24" height="24" viewBox="0 0 24 24"><title></title><circle cx="3.25" cy="12" r="3.25"></circle><circle cx="12" cy="12" r="3.25"></circle><circle cx="20.75" cy="12" r="3.25"></circle></svg></div><div class="ui-lib-pagination__item ui-lib-pagination__item_page" aria-label="" role="button" tabindex="0">32</div><div class="ui-lib-pagination__item ui-lib-pagination__item_nav" aria-label="Next" role="button" tabindex="0"><svg tabindex="0" version="1.1" xmlns="http://www.w3.org/2000/svg" data-key="" class="ui-lib-pagination__item-icon ui-lib-icon" width="24" height="24" viewBox="0 0 24 24"><title></title><path d="M23.987,12a2.411,2.411,0,0,0-.814-1.8L11.994.361a1.44,1.44,0,0,0-1.9,2.162l8.637,7.6a.25.25,0,0,1-.165.437H1.452a1.44,1.44,0,0,0,0,2.88H18.563a.251.251,0,0,1,.165.438l-8.637,7.6a1.44,1.44,0,1,0,1.9,2.161L23.172,13.8A2.409,2.409,0,0,0,23.987,12Z"></path></svg></div></div></div></div>
I used this code to get the number of elements
List<WebElement> TotalSearchResults = driver.findElements(By.xpath("//div[@class='ui-lib-sidebar-grid__content']//div[contains(@class,'ui-lib-category-list ui-lib-category-list-dummy')]/div"));
int TotalSearchCountSize = TotalSearchResults.size();
System.out.println("Total Number of Search results " +TotalSearchCountSize);
When running the code the number of elements in output is shown as 0
Solution
The output is shown as 0 as WebDriver instance is initiating the search for the elements even before the desired WeElements have properly rendered within the HTML DOM. In such cases you have to synchronize the WebDriver with the Browsing Context using WebDriverWait.
Solution
To print the number of elements you have to induce WebDriverWait for the visibilityOfAllElementsLocatedBy()
and you can use the following locator strategy:
Using xpath:
System.out.println(new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//div[@class='ui-lib-sidebar-grid__content']//div[contains(@class,'ui-lib-category-list ui-lib-category-list-dummy')]/div"))).size());
Answered By - undetected Selenium
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.