1

How do I select the "C" option of my ComboBox "opcao_pesquisa"?

<form name="Form1" method="post">
    <input type="hidden" name="operacao" value="1">
    <input type="hidden" name="d" value="">
    <input type="hidden" name="equipe" value="">
    <input type="text" name="conteudo" maxlength="200" size="20" onkeyup="escolhe_opcao_pesquisa(this);">
    <select name="opcao_pesquisa">
        <option value="A">Ambiente</option>
        <option value="C">CNPJ</option>         
        <option value="E" selected="">Nome do Portal</option>
        <option value="P">Número do Portal</option>
        <option value="R">Rede</option>
        <option value="L">Release</option>
        <option value="S">Sufixo Login</option>         
    </select>
    <input type="submit" value="Pesquisar &gt;">
</form>

I tried the following code:

new SelectElement(driver.FindElement(By.XPath("//*@opcao_pesquisa']"))).SelectByValue("C");
2

There is syntax error in your xPath expression, an opening [ is missing and after the @ the attribute name is also missing. All in all it should be:

//select[@name='opcao_pesquisa']

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.