c# - find an element from a drop down list using webdriver -
i writing simple automated test application, have reach point have write n unit test application.
my question want assert value select user default value system, can give me hand please
this code :
iwebelement dropdownlistbox = _driver.findelement(by.id("ddlworkflow")); dropdownlistbox.click(); assert.areequal(-1, string.compare("cd-a", dropdownlistbox.text, true));
dropdown referred select element
in selenium. in order select item list, need use selectelement
class of selenium , part of webdriver.support.dll
. try below code.
selectelement selectelement = new selectelement(_driver.findelement(by.id("ddlworkflow"))); selectelement.selectbytext(dropdown item text); // or can use index selectelement.selectbyindex(dropdown item index);
for getting drop down item selected text, need use below.
selectelement.selectedoption.text;
so final code this.
assert.areequal("cd-a", selectelement.selectedoption.text, "dropdown item should selected.");
do let me know if works you.
Comments
Post a Comment