Note that there are some explanatory texts on larger screens.

plurals
  1. POHow Do I Get The Count Or Even A Text List of Children in a Div
    primarykey
    data
    text
    <p>I am using Java and Webdriver with TestNG. I have a text box where a user enters a medication name and then clicks a Go button. The program then runs a query to RxNorm and returns the Strength and Form of the medication name. The webpage has a div with an id of <code>whatDosage</code> in that div is a list of buttons with the appropriate strength/form for that medication. </p> <p>My question is, how do I get either the number of elements in that div or a list of the strength/forms displayed to the user? Ultimately, I will be making a call to RxNorm with the same medication name and comparing the results. </p> <p>I have tried the following:</p> <pre><code>(1) String resultsWebPage = driver.findElements(By.id("whatDosage")).toString(); System.out.println(resultsWebPage); (2) int resultsWebPage = driver.findElements(By.id("whatDosage")).size(); System.out.println(resultsWebPage); </code></pre> <p>The first example simple returns the id. The second only gave me an output of 1. The medication name I am entering returns 11 results into the <code>whatDosage</code> div</p> <p>The div looks like this:</p> <pre><code>&lt;div id="whatDosage" class="btn-group btn-group-vertical buttons-radio span12" role="radiogroup"&gt; &lt;input id="dosage1" class="hide" type="radio" value="20 MG Enteric Coated Capsule" name="dosage"&gt; &lt;button class="btn btn-large" rel="dosage1" role="radio" type="button"&gt;20 MG Enteric Coated Capsule&lt;/button&gt; &lt;input id="dosage2" class="hide" type="radio" value="30 MG Enteric Coated Capsule" name="dosage"&gt; &lt;button class="btn btn-large" rel="dosage2" role="radio" type="button"&gt;30 MG Enteric Coated Capsule&lt;/button&gt; &lt;input id="dosage3" class="hide" type="radio" value="60 MG Enteric Coated Capsule" name="dosage"&gt; &lt;button class="btn btn-large" rel="dosage3" role="radio" type="button"&gt;60 MG Enteric Coated Capsule&lt;/button&gt; &lt;/div&gt; </code></pre> <p>The <code>input</code> elements are hidden with the <code>button</code> elements being what are displayed on screen. </p>
    singulars
    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.
 

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