I deactivated the ScrollBars
in general with a Flag transported as an Intent to my .NET MAUI App (in the Android Platform Section MainActivity.cs
- OnCreate(...)
-Method). The ScrollBars are deactivated via .NET MAUI ScrollViewHandler.
// Retrieve the "isTestExecution" parameter provided by Appium to determine if the application is in test execution mode
bool isTestExecution = Intent?.GetBooleanExtra("isTestExecution", false) ?? false;
// Obtain the AppExecutionState service and update its IsTestExecution property
var appExecutionState = ServiceHelper.GetService<AppExecutionState>();
if (appExecutionState != null)
{
appExecutionState.IsTestExecution = isTestExecution;
}
The ScrollViewHandler
to remove the ScrollBars
was added as follows also in the MainActivity.cs
:
// Register Handler to set the ScrollBar visibility based on the IsTestExecution flag and don't show them in tests
var appExecutionState = ServiceHelper.GetService<AppExecutionState>();
if (appExecutionState?.IsTestExecution == true)
{
Microsoft.Maui.Handlers.ScrollViewHandler.Mapper.AppendToMapping("ScrollBarVisibilityInTests", (handler, view) =>
{
handler.PlatformView.SetVerticalScrollBarVisibility(ScrollBarVisibility.Never);
handler.PlatformView.SetHorizontalScrollBarVisibility(ScrollBarVisibility.Never);
});
}
Unfortunately, I have a View which has a DevExpress DXCollectionView
that comes with its ScrollBars
. This is a Control, which is probably not developed in .NET MAUI, but some native/platform code. For this the ScrollBars
are not deactivated.
I could detect it as a NestedScrollView
in my Handler
-Code. For this, I don’t see corresponding methods to set the ScrollBar
visibility. It also did not work to enable/disable them. I also tried to set the Fade-out times and the time to wait until fade-out starts by setting them to 0. But, no chance so far that they disappear or don’t fade out so slowly.
In my Test, I also determined the corresponding element which according to the Appium Inspector would be:
var element = App.FindElement(By.Id("com.myapp.app:id/dx_vertical_scrollview"));
But, I do not know what could be a way to hide the ScrollBars
from this element
.
Do you know anything for such components and how I could get them to disappear?
Problem in my tests really often is that the Screenshots are taken when ScrollBars
are still not fade out completely and unless wasting time and setting a wait time of 5 seconds each test, I don’t know if there could be a way to get rid of the ScrollBars
?