I have selected the drop-down now i want to verify the selected drop down is correct using Assert

I have noticed that the selected item has attribute "selected"

var ftpTransDropdown = Driver.FindElement(By.Id("FtpTransmittalMethods")); var selectFtpTransDrpdwn = new SelectElement(ftpTransDropdown); selectFtpTransDrpdwn.SelectByText("NIHMS-PubMed Central Deposit (manuscript-dtd)");<code>enter image description here</code>

Assert.AreEqual("NIHMS-PubMed Central Deposit (manuscript-dtd)", "

I have attached HTML screenshot


Rather than AreEqual(), I'd probably see if you can use .IsTrue() after you've selected the option.




Doing it this way, you'll still be looking at the element, but, you'll be asserting that the option with the selected attribute with a value of selected is actually the one selected in the SelectElement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.