File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
Components/test/E2ETest/Tests Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -374,7 +374,7 @@ public void CanUseJsInteropToReferenceElements()
374374 [ Fact ]
375375 public void CanUseFocusExtensionToFocusElement ( )
376376 {
377- Browser . Manage ( ) . Window . Size = new System . Drawing . Size ( 100 , 300 ) ;
377+ Browser . SetWindowSize ( 100 , 300 ) ;
378378 var appElement = Browser . MountTestComponent < ElementFocusComponent > ( ) ;
379379
380380 // y scroll position before click
@@ -408,7 +408,7 @@ public void CanUseFocusExtensionToFocusElement()
408408 [ Fact ]
409409 public void CanUseFocusExtensionToFocusSvgElement ( )
410410 {
411- Browser . Manage ( ) . Window . Size = new System . Drawing . Size ( 100 , 300 ) ;
411+ Browser . SetWindowSize ( 100 , 300 ) ;
412412 var appElement = Browser . MountTestComponent < SvgFocusComponent > ( ) ;
413413
414414 var buttonElement = appElement . FindElement ( By . Id ( "focus-button" ) ) ;
@@ -430,7 +430,7 @@ public void CanUseFocusExtensionToFocusSvgElement()
430430 [ Fact ]
431431 public void CanUseFocusExtensionToFocusElementPreventScroll ( )
432432 {
433- Browser . Manage ( ) . Window . Size = new System . Drawing . Size ( 600 , 600 ) ;
433+ Browser . SetWindowSize ( 600 , 600 ) ;
434434 var appElement = Browser . MountTestComponent < ElementFocusComponent > ( ) ;
435435
436436 var buttonElement = Browser . Exists ( By . Id ( "focus-button-prevented" ) ) ;
Original file line number Diff line number Diff line change @@ -44,6 +44,12 @@ public void NavMenuHighlightsCurrentLocation()
4444 var activeNavLinksSelector = By . CssSelector ( ".sidebar a.active" ) ;
4545 var mainHeaderSelector = By . TagName ( "h1" ) ;
4646
47+ // The sidebar is hidden if the screen is too narrow.
48+ // Without setting the window size explicitly, visibility-sensitive properties
49+ // such as IWebElement.Text can return empty strings, causing assertions to fail.
50+ // In particular, this happens in the headless mode (used when running without debugger).
51+ Browser . SetWindowSize ( 1920 , 1080 ) ;
52+
4753 // Verify we start at home, with the home link highlighted
4854 Assert . Equal ( "Hello, world!" , Browser . Exists ( mainHeaderSelector ) . Text ) ;
4955 Assert . Collection ( Browser . FindElements ( activeNavLinksSelector ) ,
Original file line number Diff line number Diff line change @@ -51,4 +51,11 @@ private static bool ShouldIgnore(LogEntry entry)
5151
5252 return false ;
5353 }
54+
55+ public static void SetWindowSize ( this IWebDriver driver , int width , int height )
56+ {
57+ ArgumentNullException . ThrowIfNull ( driver ) ;
58+
59+ driver . Manage ( ) . Window . Size = new System . Drawing . Size ( width , height ) ;
60+ }
5461}
You can’t perform that action at this time.
0 commit comments