Answer the question
In order to leave comments, you need to log in
Generic class for working with tables on a page?
Hello,
I need to write a generic class (C#) that would work with any table on the site (on the page).
So that you can take, for example, by the name of the table, pull data from it and see
if the username is present and if "yes", then press some button "delete",
"edit", click the checkbox in this line (in which there are data about the user.)
Page:
code snippet:
Answer the question
In order to leave comments, you need to log in
I write a simple class:
class DelegationData
{
public string StartDate { get; set; }
public string EndDate { get; set; }
public string Delegate { get; set; }
public bool Edit { get; set; }
public bool Delete { get; set; }
}
Then in the main page class I write:
...
public List GetTableData()
{
var listOfAllProcesses = new List();
try
{
List listOfProcesses = GetListOfTable();
foreach (var item in listOfProcesses)
{
listOfAllProcesses.Add(new DelegationData()
{
StartDate = item.FindElement(By.XPath("//*[@class='text']")).Text,
EndDate = item.FindElement(By.XPath("// *[@class='description']")).Text,
Delegatee = item.FindElement(By.ClassName("")).Text,
Edit = IsEditButtonExists(item),
Delete = IsDeleteButtonExists(item)
});
}
return listOfAllProcesses;
}
catch (Exception ex)
{
throw new Exception($"Could not get data. Error: {ex.Message}");
}
}
...
But it throws an error: Inconsistent accessibility: return type'List' is less accessible than method 'DelegationData.GetTableData()'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question