I'm working on a test automation case and I have the following problem.
On a web form I have a dropdown menu, with several items on them. I need to select one of them but only know the content which I am expecting.
From the following images I want to select 'PostgreSQL' as my option.
UI part:
HTML part:
This is the code I am using to open the dropdown:
var SourceSystem = driver.FindElement(By.XPath("/html/body/qe-config-page/div/div/div/div/div[1]/div[17]/div/div/div/div[2]/div/div/div/div/div/div/div[3]/div/div[2]/div[1]/div/div"));
SourceSystem.Click();
For the item selection on the list I've tried FindingElement by XPath which didn't work and SelectElement by Text which also found nothing.
Changes on the UI are not applicable in my case.
First Solution tested:
var SourceSystem = driver.FindElement(By.XPath("/html/body/qe-config-page/div/div/div/div/div[1]/div[17]/div/div/div/div[2]/div/div/div/div/div/div/div[3]/div/div[2]/div[1]/div/div"));
SourceSystem.Click();
var select = new SelectElement(SourceSystem);
select.SelectByText("PostgreSQL");
Result: Element should have been select but was div