1

I want to choose a specific selection in this table, my table & specific selection being:

<table border="0" align="CENTER">
    <tbody>
        <tr>
            <tr>
                <td class="FieldLabel" valign="top" nowrap="" colspan="1">
                <td valign="top" nowrap="" colspan="3">
                <select class="HandleSelectChange" name="DISPLAY_RequestingProvider" style="width:100%;" size="1">
                    <option selected="" value="">Choose One</option>
                    <option value="1134303902NMDX0NMDX0 NMDX0Company Name">Company Name - 1234567890</option>
                </select>
                </td>
           </tr>
      </tr>
    </tbody>
</table>

There are about 25 selections in this table, which is why I only included one of them.

Currently, my code can not find the element. My current code is as follows:

driver.FindElement(By.XPath("//tr[td[contains(text(),'Company Name')]]/td[2]")).Click();

1 Answer 1

2

Locate the select element and use SelectElement object to select an option by text:

IWebElement element = driver.FindElement(By.XPath("//tr[.//option = 'Company Name')]]//select[@name = 'DISPLAY_RequestingProvider']")).Click()

SelectElement selector = new SelectElement(element);
selector.SelectByText("Company Name");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.