I am looking to parameterize some tests and the only thing that changes in the tests are slider elements on the page. Here is what I was thinking of doing, just not sure how to get it over the line and working. I have tried looking at different examples but they only show how to do it if you are looking for a different string in the element. Below is my example:
[TestCase(amountTab.GreaterEqual3DSSliderValue.Text, amountTab.GreaterEqual3SDSlider)]
public void ParameterizeMoveAmountSliders(IWebElement sliderValue, IWebElement slider)
{
var statsPage = new AdminStatisticsPage(LufasWebManager.Driver);
statsPage.IsAt();
var statsDashboard = new AdminStatisticsDashboardSubpage(LufasWebManager.Driver);
statsDashboard.IsAt();
statsDashboard.ClickUniversalSettingsCard();
var configurationTab = new AdminStatsConfigurationSubPage(LufasWebManager.Driver);
configurationTab.ClickAmountTab();
var amountTab = new AdminStatsAmountSubPage(LufasWebManager.Driver);
LufasWebManager.WaitUntilElementExists(5000, amountTab.GreaterEqualNeg1SDSlider);
var currentSliderValue = sliderValue;
configurationTab.MoveSliderLeft(slider, 3);
var updatedSliderValue = sliderValue;
Assert.AreNotEqual(currentSliderValue, updatedSliderValue);
}
You can try using TestCaseSource
attribute (or similar approach with TestCaseData
one). Something along the lines:
[TestCaseSource(nameof(ParameterizeMoveAmountSlidersCases))]
public void ParameterizeMoveAmountSliders(Func<AdminStatsAmountSubPage, IWebElement> sliderValue,
Func<AdminStatsAmountSubPage, IWebElement> slider)
{
var statsPage = new AdminStatisticsPage(LufasWebManager.Driver);
statsPage.IsAt();
var statsDashboard = new AdminStatisticsDashboardSubpage(LufasWebManager.Driver);
statsDashboard.IsAt();
statsDashboard.ClickUniversalSettingsCard();
var configurationTab = new AdminStatsConfigurationSubPage(LufasWebManager.Driver);
configurationTab.ClickAmountTab();
var amountTab = new AdminStatsAmountSubPage(LufasWebManager.Driver);
LufasWebManager.WaitUntilElementExists(5000, amountTab.GreaterEqualNeg1SDSlider);
var currentSliderValue = sliderValue(amountTab);
configurationTab.MoveSliderLeft(slider(amountTab), 3);
var updatedSliderValue = sliderValue(amountTab);
Assert.AreNotEqual(currentSliderValue, updatedSliderValue);
}
public static IEnumerable<object> ParameterizeMoveAmountSlidersCases = new object[]
{
new Func<AdminStatsAmountSubPage, IWebElement>[] { amountTab => amountTab.GreaterEqual3DSSliderValue.Text, amountTab => amountTab.GreaterEqual3SDSlider },
};