@@ -26,7 +26,7 @@ public DriverService([NotNull] IScopeContextManager scopeContextManager, Browser
2626 _browserRunner = browserRunner ;
2727 }
2828
29- public RemoteWebDriver Driver => _browserRunner . Driver ;
29+ public IWebDriver Driver => _browserRunner . Driver ;
3030
3131 private readonly string SearchAttribute = ConfigServiceBase . SearchAttribute ;
3232
@@ -80,13 +80,19 @@ public ReadOnlyCollection<IWebElement> FindElementsByXpath(string path)
8080 return Driver . FindElements ( By . XPath ( path ) ) ;
8181 }
8282
83+ public object ExecuteScript ( string script , params object [ ] args )
84+ {
85+ IJavaScriptExecutor js = ( IJavaScriptExecutor ) Driver ;
86+ return js . ExecuteScript ( script , args ) ;
87+ }
88+
8389 public void ScrollTo ( IWebElement element )
8490 {
8591 var scrollElementIntoMiddle = "var viewPortHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);"
8692 + "var elementTop = arguments[0].getBoundingClientRect().top;"
8793 + "window.scrollBy(0, elementTop-(viewPortHeight/2));" ;
8894
89- Driver . ExecuteScript ( scrollElementIntoMiddle , element ) ;
95+ ExecuteScript ( scrollElementIntoMiddle , element ) ;
9096 Actions actions = new Actions ( Driver ) ;
9197 actions . MoveToElement ( element ) ;
9298 actions . Perform ( ) ;
@@ -130,8 +136,8 @@ private Uri GetUriFromRelativePath(string url)
130136 }
131137
132138 public void RemoveFocusFromActiveElement ( )
133- {
134- Driver . ExecuteScript ( "document.activeElement.blur()" ) ;
139+ {
140+ ExecuteScript ( "document.activeElement.blur()" ) ;
135141 }
136142
137143 public void DebugDumpPage ( )
@@ -165,13 +171,14 @@ public void ResizeWindow(int Height, int Width)
165171 public string MakeScreenShot ( )
166172 {
167173 var fileName = Regex . Replace ( TestContext . CurrentContext . Test . Name , @"(\\|\"")" , string . Empty ) + ".png" ;
168- Driver . GetScreenshot ( ) . SaveAsFile ( fileName , ScreenshotImageFormat . Png ) ;
174+ Screenshot screenshot = ( ( ITakesScreenshot ) Driver ) . GetScreenshot ( ) ;
175+ screenshot . SaveAsFile ( fileName , ScreenshotImageFormat . Png ) ;
169176 return fileName ;
170177 }
171178
172179 public void ScrollElementTo ( IWebElement element , int offset )
173180 {
174- Driver . ExecuteScript ( @"
181+ ExecuteScript ( @"
175182 var element = arguments[0];
176183 var offset = arguments[1];
177184 element.scrollTo({top: offset, behavior: 'smooth'});" , element , offset ) ;
0 commit comments