Note that there are some explanatory texts on larger screens.

plurals
  1. POWebDriver - Unable to locate element, extracting web page input fields
    primarykey
    data
    text
    <p>I'm trying to extract all input fields from a web page with their Title and element details and to put them in a HashMap for later use in a JUnit test like </p> <p><strong>This is the example code from the test class:</strong></p> <pre><code>accountDetails.chooseField("Date of Birth"); accountDetails.changeValueTo(dateOfBirth); </code></pre> <p><strong>That's part of the page source.</strong> I'm trying to get all of fields with tag name "input". Unfortunately while running the test I'm getting the following selenium error:</p> <blockquote> <p><strong>org.openqa.selenium.NoSuchElementException: Unable to locate element: **{"method":"tag name","selector":"input"}</strong></p> </blockquote> <pre><code>&lt;tbody&gt; &lt;tr&gt; &lt;tr class="subtitle"&gt; &lt;tr&gt; &lt;tr class="subtitle"&gt; &lt;tr&gt; &lt;tr class="subtitle"&gt; &lt;tr&gt; &lt;tr&gt; &lt;td class="caption"&gt;Staff Member&lt;/td&gt; &lt;td&gt; &lt;input id="StaffMember" type="text" maxlength="6" size="6" value="" name="StaffMember"&gt; &lt;/td&gt; &lt;tbody&gt; </code></pre> <p><strong>That's the extraction class:</strong></p> <pre><code>public class AccountDetails { WebDriver driver; WebElement accountDetailsTable; WebElement radioButton; HashMap&lt;String, WebElement&gt; fields = new HashMap&lt;String, WebElement&gt;(); WebElement addCustomerButton; public AccountDetails(WebDriver driver) { this.driver = driver; driver.switchTo().defaultContent(); driver.switchTo().frame(driver.findElement(By.name("officePane"))); driver.switchTo().frame(driver.findElement(By.name("MainArea"))); accountDetailsTable = driver.findElement(By.tagName("tbody")); addCustomerButton = accountDetailsTable.findElements(By.className("btn_def")).get(0); List&lt;WebElement&gt; tr = accountDetailsTable.findElements(By.tagName("tr")); for (WebElement el : tr) { List&lt;WebElement&gt; td = el.findElements(By.tagName("td")); if (td.size() &gt; 0) { fields.put(td.get(1).getText(), td.get(0).findElement(By.tagName("input"))); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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