0

I want to extract the select information and print to the console , already tried in every way , but selenium is unable to find the element , I've used waits implicit and explicit , and still can not .

<form style="display:inline" name="productForm" action="lib/general/navBar.php" method="get">

                        <input type="hidden" name="CSRFName" value="CSRFGuard_1364551223">

                        <input type="hidden" name="CSRFToken" value="19838e996a1a94dc508c12fab4ee5c845e4"> Projeto de Teste
    <select style="font-size: 80%;position:relative; top:-1px;" name="testproject" onchange="this.form.submit();">
             <option value="470258" title="Criação de Nova Faixa de Planos Pós PF - 106227 ">
            Criação de Nova Faixa de Planos...</option>
        <option value="469505" title="Limite de Utilização Diferente para Cliente Base que Migrou para Combo Multi - 105942" selected="selected">
            Limite de Utilização Diferente...</option>
        <option value="469489" title="Campanha 0500 Gente Especial 2016 - 106185">
            Campanha 0500 Gente Especial...</option>
        <option value="469477" title="Teste CTC 2016 - 33333333">
            Teste CTC 2016 - 33333333</option>

    </select>

2
  • Let me guess - the form is inside an iframe? Commented May 24, 2016 at 15:25
  • The system is TestLink , then yes, this ceretza inside an iframe . Commented May 24, 2016 at 15:39

1 Answer 1

2

If the element is inside an iframe, you need to be in the context of the iframe to be able to find elements inside it. Once inside, find the select element (for example, by name), instantiate a Select class instance and get the options using getOptions() method:

driver.switchTo().frame("frame_name_or_id");

Select select = Select(driver.findElement(By.name("testproject")));
List<WebElement> options = select.getOptions();

for (WebElement option : options) {
    System.out.println(option.getText());
}
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.