๐ Issue with Allure.Net.Commons and Allure.NUnit Upgrade causing Test Failures
SuravinS opened this issue ยท 6 comments
I am encountering a critical issue after upgrading to the latest versions of Allure.Net.Commons and Allure.NUnit. Previously, I was using the deprecated Allure version NUnit.Allure" Version=1.2.1.1, and my code was working fine. However, after migrating to the latest Allure versions, I had to make adjustments to my existing code, specifically in the usage of using Allure.Net.Commons;".
// Attachment code before upgrade
AllureLifecycle.Instance.AddAttachment("Page source", "application/xml", byteArray, "xml");
AllureApi.AddAttachment("Page source", "application/xml", byteArray, "xml");
// Attachment code after upgrade
AllureLifecycle.Instance.AddAttachment(screenshotPath);
AllureApi.AddAttachment(screenshotPath);
- bug report
- feature request
- support request
What is the current behavior?
After upgrading to the latest Allure.Net.Commons (2.11.0) and Allure all most all test cases getting failed
Newtonsoft.Json.JsonSerializationException : Error getting value from 'NetworkConditions' on 'OpenQA.Selenium.Chrome.ChromeDriver'. ----> OpenQA.Selenium.WebDriverException : unknown error: network conditions must be set before it can be retrieved (Session info: chrome=120.0.6099.130)
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
1.Upgrade to Allure.Net.Commons version 2.11.0.
2.Upgrade Allure.NUnit to the latest version.
3. Run selenium c# with the having help following libraries
What is the expected behavior?
Test cases should run successfully after the upgrade without causing the reported exception.
What is the motivation / use case for changing the behavior?
The motivation for the upgrade is to utilize the latest versions of Allure.Net.Commons and Allure.NUnit, benefiting from their improvements and features. The current behavior, where a significant portion of test cases fail, is unexpected and hinders the adoption of these versions.
Please tell us about your environment:
- Allure version: 2.11.0
- Test framework: selenium c#
- Allure adaptor: Allure.NUnit (2.11.0)
- Generate report using: .net 6
Other information
<ItemGroup>
<PackageReference Include="Allure.Net.Commons" Version="2.11.0" />
<PackageReference Include="Allure.NUnit" Version="2.11.0" />
<PackageReference Include="JUnitTestLogger" Version="1.1.0" />
<PackageReference Include="NTextCat" Version="0.3.65" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit.Engine.Api" Version="3.16.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23577-04" />
<PackageReference Include="WebDriverManager" Version="2.17.1" />
<PackageReference Include="DotNetSeleniumExtras.PageObjects" Version="3.11.0" />
<PackageReference Include="DotNetSeleniumExtras.PageObjects.Core" Version="4.14.1" />
<PackageReference Include="DotNetSeleniumExtras.WaitHelpers" Version="3.11.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NUnit.Console" Version="3.16.3" />
<PackageReference Include="System.Runtime" Version="4.3.1" />
<PackageReference Include="Selenium.Support" Version="4.16.2" />
<PackageReference Include="Selenium.WebDriver" Version="4.16.2" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
</ItemGroup>
)
Welcome, @SuravinS !
Could you please provide me with the code of a failing test?
Thank you for your response.
Driver initialization is currently occurring in the following manner, and it encountered failure in my method class. This is exemplified in the following scenario, wherein I employed the DoubleClickOnElement method from the BasePage class. Additionally, a majority of my cases in the base class failed, irrespective of the different methods I applied. I discerned a common factor across all methods: failure ensued whenever I parametrized the IWebElement element. Beyond this observation, I lack any further insights. It is worth noting that I have utilized this interface in the same class, designated as "protected IWebDriver driver."
if (browser.Equals("chrome", StringComparison.OrdinalIgnoreCase))
{
new DriverManager().SetUpDriver(new ChromeConfig());
ChromeOptions options = new ChromeOptions();
options.AddArgument("--incognito");
options.AddArgument("--disable-extensions");
options.AddArgument("--disable-infobars");
Drivers.Value = new ChromeDriver(options);
}
Method class
[AllureStep]
public RoundGroupListPage DoubleClickRoundGroup(string name)
{
List<IWebElement> rows = GetAllElements(roundGroupRows);
foreach (var row in rows)
{
IWebElement nameCell = row.FindElement(By.XPath("./div[contains(@class,'l2')]"));
if (GetElementText(nameCell) == name)
{
DoubleClickOnElement(row);
break;
}
}
return this;
}
BasePage class
[AllureStep]
public void DoubleClickOnElement(IWebElement element)
{
Actions act = new Actions(IWebDriverManager.GetDriver());
WaitUtil.WaitForElementClickable(element);
act.DoubleClick(element).Perform();
}
This is yet another manifestation of #438. While the issue describes parameterized tests, steps are affected as well.
Since you deal with step parameters, try excluding it from the report with [Skip]
as a workaround:
[AllureStep]
public void DoubleClickOnElement([Skip] IWebElement element)
{
Actions act = new Actions(IWebDriverManager.GetDriver());
WaitUtil.WaitForElementClickable(element);
act.DoubleClick(element).Perform();
}
The parsing mechanism has worked out for me. Thank you for the support and explanation.