In the bottom of tables in our application, we have a field that says, "Showing x to x of x entries", where x is the number of entries in the table.
I am trying to create a function that can save the last 'x' value in the above string to compare it to a new value after a record is deleted.
For instance...
Is there any straight forward way to store these values with C# or Selenium? The problem is that when the test is run, the x and y values above will consistently be different because of other tests that run previously. I know that long term I should have consistent data for tests but right now that is a problem for later.
The simplest storage is local variables, nice and clean and contained:
[TestFixture]
public class MyTests {
[Test]
public void YourTest() {
var number = 0;
number = myPageObjectModel.GetResultCount();
myPageObjectModel.Delete();
Assert.AreEqual(number - 1, myPageObjectModel.GetResultCount());
}
}
You could store the number on the class and it would be more widely available, but I feel this would start coupling your tests as they would have to run in a specific order, so I'd recommend starting with a local variable if you can.
If you are using a technology that forces you to skip between methods in different classes (like SpecFlow) it is better to preserve state between steps in a scenario context class.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.