0

I have a dropdown to select employees. But when I try to automate it, the employee list open from dropdown is not showing in HTML code. It's reflecting only when it selected. But in my code When I try to use Find element it is showing error: no such Element found.

This is my code: IWebElement Employee = driver.FindElement(By.Name("employee_ids")); Employee.Click(); IWebElement selectEmployee = driver.FindElement(By.XPath("//div[@data-id='1127']")); selectEmployee.Click();

1 Answer 1

0

I have 2 ideas. First, try use the ctrl button when you spy on the dropdown. Thay way, when the ctrl hold down you can click on the dropdown and click again on the employee you want from the dropdown. This may show you his html attribute values. Second, try to use this pseudo code for find list of all employee options ( the dropdown children ) and select from them :

IWebElement Employee = driver.FindElement(By.Name("employee_ids")); 
 Employee.Click();
 List<IWebElement> employeeOptions = driver.FindElements(... )
 foreach (IWebElement in employeeOptions)
 {
    if IWebElement.UiElement.Text = <expectedValue>
    {
        IWebElement.Click
    }
 }
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.