I would like to hear your opinion on how I am organizing our large amount of Elements found in our web application.
Currently we are using selenium to run functional test cases. Our test cases reach into the thousands.
My issue is, the current method I use to store our objects on the site is through JSON. I parse the object into a dynamic object, then I take that dynamic object and force it into a custom class.
for example if we had a login page with username, password and a login button it might look something like this
dynamic page = jsonObj.LoginPage
page.Username.ToObject<ElementObject>().OnSendKeys("Username");
page.Password.ToObject<ElementObject>().OnSendKeys("Password");
page.LoginBtn.ToObject<ElementObject>().OnClick();
The ElementObject
then finds out how to access the object and then clicks it, sends keys. what ever.
Can anyone forsee whats wrong with this? I feel like this can be done in a much better way.
{
"Login": {
"UserName": {
"Id": "Username_Input"
},
"Password": {
"Id": "Password_Input"
},
"LoginButton": {
"Id": "Login_BTN"
}
}
}
ElementObject
Class:
public class ElementObject
{
public string ClassName;
public string CssSelector;
public string Id;
public string LinkText;
public string Name;
public string PartialLinkText;
public string TagName;
public string XPath;
public ElementObject();
public int GetIndex();
public string GetText();
public string GetValue();
public void OnClick();
public void OnHover();
public void OnSelectByIndex(int pValue);
public void OnSelectByText(string pValue);
public void OnSelectByValue(string pValue);
public void OnSendKeys(string pMsg);
}