Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to search / find all results using Selenium Java Webdriver
    primarykey
    data
    text
    <p>Dear Selenium Webdriver Specialists,</p> <p>I am new to this framework and needed a bit of advice on how to locate / find all the search results from a sales property listing website. Below is a working code which has successfully found all the properties using Selenium Webdriver but I don't know how to use findElements(by...) to pick up every results returned by this website:</p> <pre><code> WebDriver driver = new FirefoxDriver(); driver.get("http://www.domain.com.au/?mode=buy"); // Enter the query string "3000" WebElement query = driver.findElement(By.xpath(".//*[@id='ctl00_SearchMoreCriteria_Radar_searchToBuy']")); query.sendKeys("3000"); WebElement searchButton = driver.findElement(By.xpath(".//*[@id='ctl00_SearchMoreCriteria_Radar_Search']")); searchButton.click(); // Sleep until the div we want is visible or 5 seconds is over long end = System.currentTimeMillis() + 5000; </code></pre> <p>Could anyone offer some advice on this query? I also like to include a pausing mechanism before locating / finding all the returned results?</p> <p>Many thanks,</p> <p>Jack </p> <hr> <p>Thank you Santoshsarma very much for your response but I am struggling to apply your suggestion onto the following returned web query page output snippet:</p> <p></p> <pre><code> &lt;h3&gt; &lt;a id="ctl00_ctl00_Content_Content_SrchResLst_rptResult_ctl01_EliteListingTemplate_hypAddress" href="/Property/For-Sale/Penthouse/VIC/Melbourne/?adid=2009775619"&gt;602/73 Flinders Lane, Melbourne&lt;/a&gt;&lt;/h3&gt; &lt;dl class="cN-featDetails"&gt; &lt;dt class="proptype"&gt;Property type&lt;/dt&gt; &lt;dd id="ctl00_ctl00_Content_Content_SrchResLst_rptResult_ctl01_EliteListingTemplate_ddPropertyType" class="propertytype type-house" title="Property type: House"&gt;House&lt;/dd&gt; &lt;dt class="bedrooms"&gt;Bedrooms&lt;/dt&gt; &lt;dd id="ctl00_ctl00_Content_Content_SrchResLst_rptResult_ctl01_EliteListingTemplate_ddBedrooms" class="bedrooms" title="Bedrooms"&gt;3&lt;/dd&gt; &lt;dt class="bathrooms"&gt;Bathrooms&lt;/dt&gt; &lt;dd id="ctl00_ctl00_Content_Content_SrchResLst_rptResult_ctl01_EliteListingTemplate_ddBathrooms" class="bathrooms" title="Bathrooms"&gt;4&lt;/dd&gt; &lt;dt class="carspaces"&gt;Car spaces&lt;/dt&gt; &lt;dd id="ctl00_ctl00_Content_Content_SrchResLst_rptResult_ctl01_EliteListingTemplate_ddCarSpaces" class="carspaces" title="Car spaces"&gt;2&lt;/dd&gt; &lt;/dl&gt; &lt;/div&gt; &lt;div class="main-wrap"&gt; &lt;ul class="photo cfix"&gt; &lt;li&gt; &lt;a id="ctl00_ctl00_Content_Content_SrchResLst_rptResult_ctl01_EliteListingTemplate_hypMainThumb" tabindex="-1" class="contain" href="/Property/For-Sale/Penthouse/VIC/Melbourne/?adid=2009775619"&gt;&lt;img id="ctl00_ctl00_Content_Content_SrchResLst_rptResult_ctl01_EliteListingTemplate_imgMainThumb" title="602/73 Flinders Lane, Melbourne" src="http://images.domain.com.au/img/2012625/18127/2009775619_1_PM.JPG?mod=120925-150000" alt="Main photo of 602/73 Flinders Lane, Melbourne - More Details" style="border-width:0px;" /&gt;&lt;/a&gt; &lt;/li&gt; &lt;li class="last"&gt; &lt;a id="ctl00_ctl00_Content_Content_SrchResLst_rptResult_ctl01_EliteListingTemplate_hypSecondThumb" tabindex="-1" class="contain" href="/Property/For-Sale/Penthouse/VIC/Melbourne/?adid=2009775619"&gt;&lt;img id="ctl00_ctl00_Content_Content_SrchResLst_rptResult_ctl01_EliteListingTemplate_imgSecondThumb" title="602/73 Flinders Lane, Melbourne" src="http://images.domain.com.au/img/2012625/18127/2009775619_2_PM.JPG?mod=120913-125823" alt="Photo of 602/73 Flinders Lane, Melbourne - More Details" style="border-width:0px;" /&gt;&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <blockquote> <p>List AllSearchResults=driver.findElements(By.id("ctl00_ctl00_Content_Content_SrchResLst_rptResult_ctl01_EliteListingTemplate_hypAddress"));</p> </blockquote> <p>There is an index in ctl01 that needs to cycle through to get all search results which would be slow according other similar threats. Is there a better approach to use findElement() on a WebElement to search just its children but I am at a lost on where to locate the root. Are you able to confirm whether this approach would work &amp; perhaps pin point where the root of the list of results from the following URL query result page: <a href="http://www.domain.com.au/Search/buy/Property/Types/Apartment-Unit-Flat/Duplex/House/New-Apartments-Off-the-Plan/New-Home-Designs/New-House-Land/Penthouse/Semi-Detached/Studio/Terrace/Townhouse/Villa/State/VIC/Area/Inner-City/Region/Melbourne-Region/Suburb/Melbourne/?bedrooms=1&amp;bathrooms=1&amp;carspaces=1&amp;from=450000&amp;searchterm=3000&amp;pois=PriSchl|1|2|2000" rel="nofollow">http://www.domain.com.au/Search/buy/Property/Types/Apartment-Unit-Flat/Duplex/House/New-Apartments-Off-the-Plan/New-Home-Designs/New-House-Land/Penthouse/Semi-Detached/Studio/Terrace/Townhouse/Villa/State/VIC/Area/Inner-City/Region/Melbourne-Region/Suburb/Melbourne/?bedrooms=1&amp;bathrooms=1&amp;carspaces=1&amp;from=450000&amp;searchterm=3000&amp;pois=PriSchl|1|2|2000</a></p> <p>Your patience for my lack of experience in this area would be very much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload