0

i'm trying for the past two hours to klick on "Herr". Would be great if you can help me guys.

Html

<div class="dropdown_box dropdown_box_anrede mandatory">
            <div style="display: block;" class="replace" id="anrede_select_replace">
                <div class="current" id="anrede_select_current">
                    <div class="text">Anrede</div>
                </div>
                <ul class="options" id="anrede_select_options" style="display:none;">
                    <li id="anrede_select_Herr"><div class="text">Herr</div></li><li id="anrede_select_Frau"><div class="text">Frau</div></li>
                </ul>
            </div>
        </div>

code right now

driver.findElement(By.xpath("//div[@id='anrede_select_current']/div']/div")).click();
driver.findElement(By.xpath("//li[@id='anrede_select_Herr']/div")).click();

Thanks

2
  • 1
    ul tag display is set to none, it is not visible, so all the enclosed li tags are also not visible. If it is not visible webdriver wont find it. Commented Aug 17, 2016 at 10:44
  • Thanks, have to wait a second until it is visible. Commented Aug 17, 2016 at 10:55

2 Answers 2

2

You should try to click on <div> with id anrede_select_replace first then try using WebDriverWait to wait until option with id anrede_select_Herr getting visible as below :-

driver.findElement(By.id("anrede_select_replace")).click();

WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement herr = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("anrede_select_Herr"));
herr.click();
Sign up to request clarification or add additional context in comments.

Comments

1

You need to make it visible first by opening the dropdown

driver.findElement(By.className("dropdown_box_anrede")).click();
// or
driver.findElement(By.id("anrede_select_replace")).click();

And then you can click on the option

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.