As the title says, I've been trying to sift through a DOM that has a bunch of "inbox" messages that are all lined up in a div. I've been trying just to grab the first inbox message's div and get it's id value and set it as an extracted value. Once I click on the message, and and come back to the page, it no longer is marked as "unread" and I want to grab that same id again to compare. (these messages are sorted by most recent, so it will always be the first message.)
You can see in the code block below that the unread messages are marked with a specific class, which lets me grab the first message. I also tried grabbing it as an element type (not using the <HtmlDiv>), and getting the ID via that way, it also didn't work.
Since these messages all have unique, generated ids based on their content, I haven't been able to work out a way to extract and compare them. Let me know if you need anything else from me, and I appreciate the help.
[CodedStep(@"Extract id of first new inbox message")]
public void extractFirstNewInboxMessage()
{
HtmlDiv firstMessageElement = ActiveBrowser.Find.ByAttributes<
HtmlDiv
>("class= row message unread");
string id = firstMessageElement.ID;
SetExtractedValue("firstNewMessageElementID", id);
}
[CodedStep(@"Extract id of first inbox message")]
public void extractFirstOldInboxMessage()
{
HtmlDiv firstMessageElement = ActiveBrowser.Find.ByAttributes<
HtmlDiv
>("class= row message");
SetExtractedValue("firstOldMessageElementID", firstMessageElement.ID);
}
[CodedStep(@"compare extracted inbox messages")]
public void compareInboxMessage()
{
string newMessage = GetExtractedValue("firstNewMessageElementID").ToString();
string oldMessage = GetExtractedValue("firstOldMessageElementID").ToString;
//bool value
bool a = false;
if (newMessage == oldMessage)
{
a = true;
}
Assert.IsTrue(a);
}