├── .gitattributes ├── .gitignore ├── AllDriversExample ├── AllDriversExample.csproj ├── App.config ├── App.xaml ├── App.xaml.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings └── packages.config ├── AsyncFirefoxDriver ├── AsyncFirefoxDriver.cs ├── AsyncFirefoxDriver.csproj ├── AsyncFirefoxDriver.nuspec ├── FirefoxDriverConfig.cs ├── FirefoxPreferences.cs ├── FirefoxProfilesWorker.cs ├── IAsyncFirefoxDriver.cs ├── IAsyncWebBrowserClient │ ├── FirefoxDriverActionExecutor.cs │ ├── FirefoxDriverAlert.cs │ ├── FirefoxDriverCoordinates.cs │ ├── FirefoxDriverElements.cs │ ├── FirefoxDriverJavaScriptExecutor.cs │ ├── FirefoxDriverKeyboard.cs │ ├── FirefoxDriverMouse.cs │ ├── FirefoxDriverNavigation.cs │ ├── FirefoxDriverOptions.cs │ ├── FirefoxDriverScreenshot.cs │ ├── FirefoxDriverTargetLocator.cs │ ├── FirefoxDriverTimeouts.cs │ ├── FirefoxDriverTouchScreen.cs │ ├── FirefoxDriverWindow.cs │ ├── ResultValueConverter.cs │ └── TimeoutType.cs ├── IniFileReader.cs ├── KeyValuePairVM.cs ├── MarionetteComands │ ├── AcceptDialogCommand.cs │ ├── ClearElementCommand.cs │ ├── ClearImportedScriptsCommand.cs │ ├── ClickElementCommand.cs │ ├── CloseChromeWindowCommand.cs │ ├── CloseCommand.cs │ ├── DismissDialogCommand.cs │ ├── ExecuteAsyncScriptCommand.cs │ ├── ExecuteScriptCommand.cs │ ├── FindElementCommand.cs │ ├── FindElementsCommand.cs │ ├── GetActiveElementCommand.cs │ ├── GetActiveFrameCommand.cs │ ├── GetChromeWindowHandleCommand.cs │ ├── GetChromeWindowHandlesCommand.cs │ ├── GetCommand.cs │ ├── GetContextCommand.cs │ ├── GetCurrentUrlCommand.cs │ ├── GetElementAttributeCommand.cs │ ├── GetElementPropertyCommand.cs │ ├── GetElementRectCommand.cs │ ├── GetElementTagNameCommand.cs │ ├── GetElementTextCommand.cs │ ├── GetElementValueOfCssPropertyCommand.cs │ ├── GetPageSourceCommand.cs │ ├── GetTextFromDialogCommand.cs │ ├── GetTimeoutsCommand.cs │ ├── GetTitleCommand.cs │ ├── GetWindowHandleCommand.cs │ ├── GetWindowHandlesCommand.cs │ ├── GetWindowPositionCommand.cs │ ├── GetWindowSizeCommand.cs │ ├── GetWindowTypeCommand.cs │ ├── GoBackCommand.cs │ ├── GoForwardCommand.cs │ ├── ImportScriptCommand.cs │ ├── IsElementDisplayedCommand.cs │ ├── IsElementEnabledCommand.cs │ ├── IsElementSelectedCommand.cs │ ├── MaximizeWindowCommand.cs │ ├── NewSessionCommand.cs │ ├── PerformActionsCommand.cs │ ├── RefreshCommand.cs │ ├── ReleaseActionsCommand.cs │ ├── SendKeysToDialogCommand.cs │ ├── SendKeysToElementCommand.cs │ ├── SessionTearDownCommand.cs │ ├── SetContextCommand.cs │ ├── SetTimeoutsCommand.cs │ ├── SetWindowPositionCommand.cs │ ├── SetWindowSizeCommand.cs │ ├── SwitchToFrameCommand.cs │ ├── SwitchToParentFrameCommand.cs │ ├── SwitchToWindowCommand.cs │ └── TakeScreenshotCommand.cs ├── MarionetteDebuggerCommand.cs ├── MarionetteDebuggerCommandString.cs ├── Properties │ └── AssemblyInfo.cs ├── js │ └── mymarionetteserver.js └── packages.config ├── AsyncFirefoxDriverExample ├── App.config ├── App.xaml ├── App.xaml.cs ├── AsyncFirefoxDriverExample.csproj ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings └── packages.config ├── AsyncWebDriver.sln ├── AsyncWebDriver ├── AsyncWebDriver.csproj ├── AsyncWebDriver.nuspec ├── AsyncWebDriver │ ├── AsyncWebElement.cs │ ├── RemoteTargetLocator.cs │ ├── TaskExt.cs │ ├── TaskRemoteTargetLocatorExtensions.cs │ └── WebDriver.cs ├── By.cs ├── Exceptions │ ├── ElementClickInterceptedException.cs │ ├── ElementNotInteractableException.cs │ ├── ElementNotSelectableException.cs │ ├── ElementNotVisibleException.cs │ ├── InvalidElementStateException.cs │ ├── InvalidSelectorException.cs │ ├── NoAlertPresentException.cs │ ├── NoSuchElementException.cs │ ├── NoSuchFrameException.cs │ ├── NoSuchWindowException.cs │ ├── NotFoundException.cs │ ├── StaleElementReferenceException.cs │ ├── UnhandledAlertException.cs │ ├── WebDriverException.cs │ └── WebDriverTimeoutException.cs ├── Extensions │ ├── TaskCollectionsExtensions.cs │ ├── TaskISearchContextExtensions.cs │ ├── TaskIWebDriverExtensions.cs │ ├── TaskIWebDriverTargetLocatorExtensions.cs │ ├── TaskIWebElementExtensions.cs │ ├── TaskStringExtensions.cs │ └── TaskWebSizeWebPointExtensions.cs ├── IHasInputDevices.cs ├── IHasTouchScreen.cs ├── ISearchContext.cs ├── IWebDriver.cs ├── IWebDriverTargetLocator.cs ├── IWebElement.cs ├── Interactions │ ├── ActionBuilder.cs │ ├── Actions.cs │ ├── BuiltAction.cs │ ├── ButtonReleaseAction.cs │ ├── ClickAction.cs │ ├── ClickAndHoldAction.cs │ ├── CompositeAction.cs │ ├── ContextClickAction.cs │ ├── DoubleClickAction.cs │ ├── DoubleTapAction.cs │ ├── FlickAction.cs │ ├── KeyDownAction.cs │ ├── KeyInputDevice.cs │ ├── KeyUpAction.cs │ ├── KeyboardAction.cs │ ├── LongPressAction.cs │ ├── MouseAction.cs │ ├── MoveMouseAction.cs │ ├── MoveToOffsetAction.cs │ ├── PointerInputDevice.cs │ ├── ScreenMoveAction.cs │ ├── ScreenPressAction.cs │ ├── ScreenReleaseAction.cs │ ├── ScrollAction.cs │ ├── SendKeysAction.cs │ ├── SingleKeyAction.cs │ ├── SingleTapAction.cs │ ├── TouchAction.cs │ ├── TouchActions.cs │ └── WebDriverAction.cs ├── Internal │ ├── IFindsByClassName.cs │ ├── IFindsByCssSelector.cs │ ├── IFindsById.cs │ ├── IFindsByLinkText.cs │ ├── IFindsByName.cs │ ├── IFindsByPartialLinkText.cs │ ├── IFindsByTagName.cs │ ├── IFindsByXPath.cs │ ├── IWebElementReference.cs │ ├── IWrapsDriver.cs │ ├── IWrapsElement.cs │ └── ReturnedCookie.cs └── SyncWrapper │ ├── SyncAlert.cs │ ├── SyncCookieJar.cs │ ├── SyncCoordinates.cs │ ├── SyncKeyboard.cs │ ├── SyncLogs.cs │ ├── SyncMouse.cs │ ├── SyncNavigation.cs │ ├── SyncOptions.cs │ ├── SyncRemoteTargetLocator.cs │ ├── SyncTimeouts.cs │ ├── SyncWebDriver.cs │ ├── SyncWebDriver1.cs │ ├── SyncWebElement.cs │ ├── SyncWebElement1.cs │ └── SyncWindow.cs ├── LICENSE.txt ├── NOTICE ├── README.md ├── THIRD-PARTY-NOTICES ├── WebBrowserCommunication ├── AsyncProducerConsumerCollection.cs ├── DebuggerClient.cs ├── DebuggerClientMarionette.cs ├── DebuggerCommand.cs ├── DebuggerCommandException.cs ├── DebuggerConnection.cs ├── DebuggerConnectionMarionette.cs ├── IDebuggerClient.cs ├── IDebuggerConnection.cs ├── INetworkClient.cs ├── INetworkClientFactory.cs ├── LiveLogger.cs ├── MessageEventArgs.cs ├── NetworkClientFactory.cs ├── Properties │ └── AssemblyInfo.cs ├── TcpNetworkClient.cs ├── WebBrowserCommunication.csproj ├── WebSocketNetworkClient.cs ├── WebSocketStream.cs └── packages.config └── ZuRequestListener ├── Properties └── AssemblyInfo.cs ├── ZuRequestInfo.cs ├── ZuRequestListener.cs ├── ZuRequestListener.csproj ├── js ├── TracingListener.js └── base64.js └── packages.config /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | 65 | -------------------------------------------------------------------------------- /AllDriversExample/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /AllDriversExample/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AllDriversExample/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace AllDriversExample 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /AllDriversExample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("AllDriversExaple")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("AllDriversExaple")] 15 | [assembly: AssemblyCopyright("Copyright © 2017")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /AllDriversExample/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace AllDriversExample.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /AllDriversExample/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /AllDriversExample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/AsyncFirefoxDriver.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $title$ 7 | $author$ 8 | $author$ 9 | https://github.com/ToCSharp/AsyncWebDriver/blob/master/LICENSE.txt 10 | https://github.com/ToCSharp/AsyncWebDriver 11 | false 12 | $description$ 13 | Initial release. 14 | Copyright Oleg Zudov 2017 15 | AsyncFirefoxDriver Firefox WebDriver 16 | 17 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/IAsyncFirefoxDriver.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json.Linq; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Zu.WebBrowser.Communication; 7 | using Zu.WebBrowser.Firefox; 8 | 9 | namespace Zu.Firefox 10 | { 11 | public interface IAsyncFirefoxDriver: IAsyncWebBrowserClientFirefox 12 | { 13 | IDebuggerClient ClientMarionette { get; set; } 14 | 15 | } 16 | } -------------------------------------------------------------------------------- /AsyncFirefoxDriver/IAsyncWebBrowserClient/FirefoxDriverCoordinates.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.WebBrowser.AsyncInteractions; 6 | using Zu.WebBrowser.BasicTypes; 7 | 8 | namespace Zu.Firefox 9 | { 10 | public class FirefoxDriverCoordinates: ICoordinates 11 | { 12 | private IAsyncFirefoxDriver asyncFirefoxDriver; 13 | 14 | public FirefoxDriverCoordinates(IAsyncFirefoxDriver asyncFirefoxDriver) 15 | { 16 | this.asyncFirefoxDriver = asyncFirefoxDriver; 17 | } 18 | 19 | public string AuxiliaryLocator => throw new System.NotImplementedException(); 20 | 21 | public Task LocationInDom(CancellationToken cancellationToken = default(CancellationToken)) 22 | { 23 | throw new System.NotImplementedException(); 24 | } 25 | 26 | public Task LocationInViewport(CancellationToken cancellationToken = default(CancellationToken)) 27 | { 28 | throw new System.NotImplementedException(); 29 | } 30 | 31 | public Task LocationOnScreen(CancellationToken cancellationToken = default(CancellationToken)) 32 | { 33 | throw new System.NotImplementedException(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /AsyncFirefoxDriver/IAsyncWebBrowserClient/FirefoxDriverKeyboard.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | using System; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.WebBrowser.AsyncInteractions; 6 | 7 | namespace Zu.Firefox 8 | { 9 | internal class FirefoxDriverKeyboard : IKeyboard 10 | { 11 | private IAsyncFirefoxDriver asyncFirefoxDriver; 12 | public FirefoxDriverKeyboard(IAsyncFirefoxDriver asyncFirefoxDriver) 13 | { 14 | this.asyncFirefoxDriver = asyncFirefoxDriver; 15 | } 16 | 17 | public async Task PressKey(string keyToPress, CancellationToken cancellationToken = default (CancellationToken)) 18 | { 19 | await asyncFirefoxDriver.CheckConnected(cancellationToken).ConfigureAwait(false); 20 | var el = await asyncFirefoxDriver.TargetLocator.SwitchToActiveElement(cancellationToken).ConfigureAwait(false); 21 | await asyncFirefoxDriver.Elements.SendKeysToElement(el, keyToPress).ConfigureAwait(false); 22 | } 23 | 24 | public async Task ReleaseKey(string keyToRelease, CancellationToken cancellationToken = default (CancellationToken)) 25 | { 26 | await asyncFirefoxDriver.CheckConnected(cancellationToken).ConfigureAwait(false); 27 | throw new NotImplementedException(); 28 | } 29 | 30 | public async Task SendKeys(string keySequence, CancellationToken cancellationToken = default (CancellationToken)) 31 | { 32 | await asyncFirefoxDriver.CheckConnected(cancellationToken).ConfigureAwait(false); 33 | var el = await asyncFirefoxDriver.TargetLocator.SwitchToActiveElement(cancellationToken).ConfigureAwait(false); 34 | await asyncFirefoxDriver.Elements.SendKeysToElement(el, keySequence).ConfigureAwait(false); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /AsyncFirefoxDriver/IAsyncWebBrowserClient/FirefoxDriverOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Zu.WebBrowser.BrowserOptions; 4 | 5 | namespace Zu.Firefox 6 | { 7 | public class FirefoxDriverOptions: IOptions 8 | { 9 | private IAsyncFirefoxDriver asyncFirefoxDriver; 10 | private FirefoxDriverWindow window; 11 | private FirefoxDriverTimeouts timeouts; 12 | 13 | public FirefoxDriverOptions(IAsyncFirefoxDriver asyncFirefoxDriver) 14 | { 15 | this.asyncFirefoxDriver = asyncFirefoxDriver; 16 | } 17 | 18 | public ICookieJar Cookies => throw new System.NotImplementedException(); 19 | 20 | public IWindow Window { get { if (window == null) window = new FirefoxDriverWindow(asyncFirefoxDriver); return window; } } 21 | 22 | public ILogs Logs => throw new System.NotImplementedException(); 23 | 24 | public ITimeouts Timeouts { get { if (timeouts == null) timeouts = new FirefoxDriverTimeouts(asyncFirefoxDriver); return timeouts; } } 25 | 26 | public bool HasLocationContext => throw new System.NotImplementedException(); 27 | 28 | public ILocationContext LocationContext => throw new System.NotImplementedException(); 29 | 30 | public bool HasApplicationCache => throw new System.NotImplementedException(); 31 | 32 | public IApplicationCache ApplicationCache => throw new System.NotImplementedException(); 33 | 34 | public ILocalStorage LocalStorage => throw new System.NotImplementedException(); 35 | 36 | public ISessionStorage SessionStorage => throw new System.NotImplementedException(); 37 | } 38 | } -------------------------------------------------------------------------------- /AsyncFirefoxDriver/IAsyncWebBrowserClient/FirefoxDriverScreenshot.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | using MyCommunicationLib.Communication.MarionetteComands; 3 | using System; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Zu.WebBrowser.AsyncInteractions; 7 | using Zu.WebBrowser.BasicTypes; 8 | 9 | namespace Zu.Firefox 10 | { 11 | internal class FirefoxDriverScreenshot : ITakesScreenshot 12 | { 13 | private IAsyncFirefoxDriver asyncFirefoxDriver; 14 | public FirefoxDriverScreenshot(IAsyncFirefoxDriver asyncFirefoxDriver) 15 | { 16 | this.asyncFirefoxDriver = asyncFirefoxDriver; 17 | } 18 | 19 | //TODO 20 | public Task GetScreenshot(CancellationToken cancellationToken = default (CancellationToken)) 21 | { 22 | return TakeScreenshot(null, null, null, null, cancellationToken); 23 | } 24 | 25 | public async Task TakeScreenshot(string elementId, string highlights, string full, string hash, CancellationToken cancellationToken = new CancellationToken()) 26 | { 27 | await asyncFirefoxDriver.CheckConnected(cancellationToken).ConfigureAwait(false); 28 | if (asyncFirefoxDriver.ClientMarionette == null) 29 | throw new Exception("error: no clientMarionette"); 30 | var comm1 = new TakeScreenshotCommand(elementId, highlights, full, hash); 31 | await asyncFirefoxDriver.ClientMarionette.SendRequestAsync(comm1, cancellationToken).ConfigureAwait(false); 32 | if (comm1.Error != null) 33 | throw new WebBrowserException(comm1.Error); 34 | return new Screenshot((string)comm1.Result?["value"]); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /AsyncFirefoxDriver/IAsyncWebBrowserClient/TimeoutType.cs: -------------------------------------------------------------------------------- 1 | namespace Zu.Firefox 2 | { 3 | public enum TimeoutType 4 | { 5 | @implicit = 0, 6 | script = 1, 7 | page_load = 2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/KeyValuePairVM.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using System.Collections.Generic; 4 | 5 | namespace Zu.Firefox 6 | { 7 | public class KeyValuePairVM 8 | { 9 | private KeyValuePair v; 10 | 11 | public KeyValuePairVM(KeyValuePair v) 12 | { 13 | this.v = v; 14 | } 15 | 16 | public string Name => v.Key; 17 | public string Val => v.Value; 18 | 19 | public override string ToString() 20 | { 21 | return $"{v.Key} ({v.Value})"; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/AcceptDialogCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | 6 | namespace MyCommunicationLib.Communication.MarionetteComands 7 | { 8 | public class AcceptDialogCommand : MarionetteDebuggerCommand 9 | { 10 | public AcceptDialogCommand(int id = 0, string commandName = "acceptDialog") : base(id, commandName) 11 | { 12 | } 13 | public override void ProcessResponse(JToken response) 14 | { 15 | base.ProcessResponse(response); 16 | } 17 | 18 | public override string ToString() 19 | { 20 | return JsonConvert.SerializeObject( 21 | new object[] 22 | { 23 | 0, 24 | Id, 25 | CommandName, 26 | 27 | }); 28 | 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/ClearElementCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class ClearElementCommand : MarionetteDebuggerCommand 14 | { 15 | public ClearElementCommand(string elementId, int id = 0, string commandName = "clearElement") : base(id, commandName) 16 | { 17 | ElementId = elementId; 18 | } 19 | 20 | public string ElementId { get; set; } 21 | 22 | public override void ProcessResponse(JToken response) 23 | { 24 | base.ProcessResponse(response); 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return JsonConvert.SerializeObject( 30 | new object[] 31 | { 32 | 0, 33 | Id, 34 | CommandName, 35 | new { 36 | id = ElementId, 37 | } 38 | 39 | }); 40 | 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/ClearImportedScriptsCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class ClearImportedScriptsCommand : MarionetteDebuggerCommand 14 | { 15 | /** 16 | * Clear all scripts that are imported into the JS evaluation runtime. 17 | * 18 | * Scripts can be imported using the {@code importScript} command. 19 | */ 20 | public ClearImportedScriptsCommand(int id = 0, string commandName = "clearImportedScripts") : base(id, commandName) 21 | { 22 | } 23 | 24 | public override void ProcessResponse(JToken response) 25 | { 26 | base.ProcessResponse(response); 27 | } 28 | 29 | public override string ToString() 30 | { 31 | return JsonConvert.SerializeObject( 32 | new object[] 33 | { 34 | 0, 35 | Id, 36 | CommandName, 37 | 38 | }); 39 | 40 | } 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/ClickElementCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class ClickElementCommand : MarionetteDebuggerCommand 14 | { 15 | public ClickElementCommand(string elementId, int id = 0, string commandName = "clickElement") : base(id, commandName) 16 | { 17 | ElementId = elementId; 18 | } 19 | 20 | public string ElementId { get; set; } 21 | 22 | public override void ProcessResponse(JToken response) 23 | { 24 | base.ProcessResponse(response); 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return JsonConvert.SerializeObject( 30 | new object[] 31 | { 32 | 0, 33 | Id, 34 | CommandName, 35 | new { 36 | id = ElementId, 37 | } 38 | 39 | }); 40 | 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/CloseChromeWindowCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class CloseChromeWindowCommand : MarionetteDebuggerCommand 14 | { 15 | public CloseChromeWindowCommand(int id = 0, string commandName = "closeChromeWindow") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | 33 | }); 34 | 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/CloseCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class CloseCommand : MarionetteDebuggerCommand 14 | { 15 | public CloseCommand(int id = 0, string commandName = "close") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | 33 | }); 34 | 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/DismissDialogCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class DismissDialogCommand : MarionetteDebuggerCommand 14 | { 15 | public DismissDialogCommand(int id = 0, string commandName = "dismissDialog") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | 33 | }); 34 | 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/ExecuteAsyncScriptCommand.cs: -------------------------------------------------------------------------------- 1 |  2 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using Newtonsoft.Json; 5 | using Newtonsoft.Json.Linq; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace MyCommunicationLib.Communication.MarionetteComands 13 | { 14 | public class ExecuteAsyncScriptCommand : MarionetteDebuggerCommand 15 | { 16 | public ExecuteAsyncScriptCommand(string code, int id = 0) : base(id, "executeAsyncScript") 17 | { 18 | Code = code; 19 | } 20 | 21 | public string Code { get; set; } 22 | 23 | 24 | public object[] Args { get; set; } = new object[0]; 25 | public bool newSandbox { get; set; } = false; 26 | public string sandbox { get; set; } 27 | public object scriptTimeout { get; set; } 28 | public bool specialPowers { get; set; } = false; 29 | public string filename { get; set; } = null; 30 | 31 | public override void ProcessResponse(JToken response) 32 | { 33 | base.ProcessResponse(response); 34 | } 35 | 36 | public override string ToString() 37 | { 38 | if (sandbox != null) 39 | { 40 | return JsonConvert.SerializeObject( 41 | new object[] 42 | { 43 | 0, 44 | Id, 45 | "executeAsyncScript", 46 | new { 47 | args = Args, 48 | sandbox = sandbox, 49 | newSandbox = newSandbox, 50 | script = Code, 51 | scriptTimeout = scriptTimeout, 52 | specialPowers = specialPowers, 53 | filename = filename 54 | } 55 | 56 | }); 57 | 58 | } 59 | return JsonConvert.SerializeObject( 60 | new object[] 61 | { 62 | 0, 63 | Id, 64 | "executeAsyncScript", 65 | new { 66 | args = Args, 67 | newSandbox = newSandbox, 68 | script = Code, 69 | scriptTimeout = scriptTimeout, 70 | specialPowers = specialPowers, 71 | filename = filename 72 | } 73 | 74 | }); 75 | 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/ExecuteScriptCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class ExecuteScriptCommand : MarionetteDebuggerCommand 14 | { 15 | public ExecuteScriptCommand(string code, int id = 0) : base(id, "executeScript") 16 | { 17 | Code = code; 18 | } 19 | 20 | public string Code { get; set; } 21 | 22 | 23 | public object[] Args { get; set; } = new object[0]; 24 | public bool newSandbox { get; set; } = false; 25 | public string sandbox { get; set; } 26 | public object scriptTimeout { get; set; } 27 | public bool specialPowers { get; set; } = false; 28 | public string filename { get; set; } = null; 29 | 30 | public override void ProcessResponse(JToken response) 31 | { 32 | base.ProcessResponse(response); 33 | } 34 | 35 | public override string ToString() 36 | { 37 | if (sandbox != null) 38 | { 39 | return JsonConvert.SerializeObject( 40 | new object[] 41 | { 42 | 0, 43 | Id, 44 | "executeScript", 45 | new { 46 | args = Args, 47 | sandbox = sandbox, 48 | newSandbox = newSandbox, 49 | script = Code, 50 | scriptTimeout = scriptTimeout, 51 | specialPowers = specialPowers, 52 | filename = filename 53 | } 54 | 55 | }); 56 | 57 | } 58 | return JsonConvert.SerializeObject( 59 | new object[] 60 | { 61 | 0, 62 | Id, 63 | "executeScript", 64 | new { 65 | args = Args, 66 | newSandbox = newSandbox, 67 | script = Code, 68 | scriptTimeout = scriptTimeout, 69 | specialPowers = specialPowers, 70 | filename = filename 71 | } 72 | 73 | }); 74 | 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/FindElementCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class FindElementCommand : MarionetteDebuggerCommand 14 | { 15 | public FindElementCommand(string strategy, string expr, string startNode = null, int id = 0, string commandName = "findElement") : base(id, commandName) 16 | { 17 | Strategy = strategy; 18 | Expr = expr; 19 | StartNode = startNode; 20 | } 21 | 22 | public string Strategy { get; set; } 23 | public string Expr { get; set; } 24 | public string StartNode { get; set; } 25 | 26 | public override void ProcessResponse(JToken response) 27 | { 28 | base.ProcessResponse(response); 29 | } 30 | 31 | public override string ToString() 32 | { 33 | if (StartNode == null) 34 | { 35 | return JsonConvert.SerializeObject( 36 | new object[] 37 | { 38 | 0, 39 | Id, 40 | "findElement", 41 | new { 42 | @using = Strategy, 43 | value = Expr, 44 | } 45 | 46 | }); 47 | } 48 | else 49 | { 50 | return JsonConvert.SerializeObject( 51 | new object[] 52 | { 53 | 0, 54 | Id, 55 | "findElement", 56 | new { 57 | @using = Strategy, 58 | value = Expr, 59 | element = StartNode 60 | } 61 | 62 | }); 63 | } 64 | 65 | //if (StartNode == null) return $"[0, {Id}, \"{CommandName}\", {{\"using\" : \"{Strategy}\", \"value\": \"{Expr?.Replace("\"", "\\\"")}\"}} ]"; 66 | //return $"[0, {Id}, \"{CommandName}\", {{\"using\" : \"{Strategy}\", \"value\": \"{Expr?.Replace("\"", "\\\"")}\", \"element\": \"{StartNode.Replace("\"", "\\\"")}\"}} ]"; 67 | 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/FindElementsCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class FindElementsCommand : MarionetteDebuggerCommand 14 | { 15 | public FindElementsCommand(string strategy, string expr, string startNode = null, int id = 0, string commandName = "findElements") : base(id, commandName) 16 | { 17 | Strategy = strategy; 18 | Expr = expr; 19 | StartNode = startNode; 20 | } 21 | 22 | public string Strategy { get; set; } 23 | public string Expr { get; set; } 24 | public string StartNode { get; set; } 25 | 26 | public override void ProcessResponse(JToken response) 27 | { 28 | base.ProcessResponse(response); 29 | } 30 | 31 | public override string ToString() 32 | { 33 | if (StartNode == null) 34 | { 35 | return JsonConvert.SerializeObject( 36 | new object[] 37 | { 38 | 0, 39 | Id, 40 | "findElements", 41 | new { 42 | @using = Strategy, 43 | value = Expr, 44 | } 45 | 46 | }); 47 | } 48 | else 49 | { 50 | return JsonConvert.SerializeObject( 51 | new object[] 52 | { 53 | 0, 54 | Id, 55 | "findElements", 56 | new { 57 | @using = Strategy, 58 | value = Expr, 59 | element = StartNode 60 | } 61 | 62 | }); 63 | } 64 | //if (StartNode == null) return $"[0, {Id}, \"{CommandName}\", {{\"using\" : \"{Strategy}\", \"value\": \"{Expr?.Replace("\"", "\\\"")}\"}} ]"; 65 | //return $"[0, {Id}, \"{CommandName}\", {{\"using\" : \"{Strategy}\", \"value\": \"{Expr?.Replace("\"", "\\\"")}\", \"element\": \"{StartNode.Replace("\"", "\\\"")}\"}} ]"; 66 | 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetActiveElementCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetActiveElementCommand : MarionetteDebuggerCommand 14 | { 15 | public GetActiveElementCommand(int id = 0, string commandName = "getActiveElement") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | }); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetActiveFrameCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetActiveFrameCommand : MarionetteDebuggerCommand 14 | { 15 | public GetActiveFrameCommand(int id = 0, string commandName = "getActiveFrame") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | }); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetChromeWindowHandleCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetChromeWindowHandleCommand : MarionetteDebuggerCommand 14 | { 15 | public GetChromeWindowHandleCommand(int id = 0, string commandName = "getChromeWindowHandle") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | }); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetChromeWindowHandlesCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetChromeWindowHandlesCommand : MarionetteDebuggerCommand 14 | { 15 | public GetChromeWindowHandlesCommand(int id = 0, string commandName = "getChromeWindowHandles") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | }); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetCommand : MarionetteDebuggerCommand 14 | { 15 | /// 16 | /// Navigate to given URL. 17 | /// 18 | /// 19 | public GetCommand(string url, int id = 0, string commandName = "get") : base(id, commandName) 20 | { 21 | Url = url; 22 | } 23 | public string Url { get; set; } 24 | public override void ProcessResponse(JToken response) 25 | { 26 | base.ProcessResponse(response); 27 | } 28 | 29 | public override string ToString() 30 | { 31 | return JsonConvert.SerializeObject( 32 | new object[] 33 | { 34 | 0, 35 | Id, 36 | CommandName, 37 | new { 38 | url = Url 39 | } 40 | 41 | }); 42 | 43 | } 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetContextCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetContextCommand : MarionetteDebuggerCommand 14 | { 15 | public GetContextCommand(int id = 0, string commandName = "getContext") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | }); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetCurrentUrlCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetCurrentUrlCommand : MarionetteDebuggerCommand 14 | { 15 | public GetCurrentUrlCommand(int id = 0, string commandName = "getCurrentUrl") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | }); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetElementAttributeCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetElementAttributeCommand : MarionetteDebuggerCommand 14 | { 15 | public GetElementAttributeCommand(string elementId, string attrName, int id = 0, string commandName = "getElementAttribute") : base(id, commandName) 16 | { 17 | ElementId = elementId; 18 | AttrName = attrName; 19 | } 20 | 21 | public string ElementId { get; set; } 22 | public string AttrName { get; set; } 23 | 24 | public override void ProcessResponse(JToken response) 25 | { 26 | base.ProcessResponse(response); 27 | } 28 | 29 | public override string ToString() 30 | { 31 | return JsonConvert.SerializeObject( 32 | new object[] 33 | { 34 | 0, 35 | Id, 36 | CommandName, 37 | new { 38 | id = ElementId, 39 | name = AttrName 40 | } 41 | 42 | }); 43 | //return $"[0, {Id}, \"{CommandName}\", {{\"id\": \"{ElementId}\", \"name\": \"{AttrName}\"}} ]"; 44 | 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetElementPropertyCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetElementPropertyCommand : MarionetteDebuggerCommand 14 | { 15 | public GetElementPropertyCommand(string elementId, string propName, int id = 0, string commandName = "getElementProperty") : base(id, commandName) 16 | { 17 | ElementId = elementId; 18 | PropertyName = propName; 19 | } 20 | 21 | public string ElementId { get; set; } 22 | public string PropertyName { get; set; } 23 | 24 | public override void ProcessResponse(JToken response) 25 | { 26 | base.ProcessResponse(response); 27 | } 28 | 29 | public override string ToString() 30 | { 31 | return JsonConvert.SerializeObject( 32 | new object[] 33 | { 34 | 0, 35 | Id, 36 | CommandName, 37 | new { 38 | id = ElementId, 39 | name = PropertyName 40 | } 41 | 42 | }); 43 | //return $"[0, {Id}, \"{CommandName}\", {{\"id\": \"{ElementId}\", \"name\": \"{PropertyName}\"}} ]"; 44 | 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetElementRectCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetElementRectCommand : MarionetteDebuggerCommand 14 | { 15 | public GetElementRectCommand(string elementId, int id = 0, string commandName = "getElementRect") : base(id, commandName) 16 | { 17 | ElementId = elementId; 18 | } 19 | 20 | public string ElementId { get; set; } 21 | 22 | public override void ProcessResponse(JToken response) 23 | { 24 | base.ProcessResponse(response); 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return JsonConvert.SerializeObject( 30 | new object[] 31 | { 32 | 0, 33 | Id, 34 | CommandName, 35 | new { 36 | id = ElementId, 37 | } 38 | 39 | }); 40 | //return $"[0, {Id}, \"{CommandName}\", {{\"id\": \"{ElementId}\"}} ]"; 41 | 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetElementTagNameCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetElementTagNameCommand : MarionetteDebuggerCommand 14 | { 15 | public GetElementTagNameCommand(string elementId, int id = 0, string commandName = "getElementTagName") : base(id, commandName) 16 | { 17 | ElementId = elementId; 18 | } 19 | public string ElementId { get; set; } 20 | 21 | public override void ProcessResponse(JToken response) 22 | { 23 | base.ProcessResponse(response); 24 | } 25 | 26 | public override string ToString() 27 | { 28 | return JsonConvert.SerializeObject( 29 | new object[] 30 | { 31 | 0, 32 | Id, 33 | CommandName, 34 | new { 35 | id = ElementId, 36 | } 37 | 38 | }); 39 | 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetElementTextCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetElementTextCommand : MarionetteDebuggerCommand 14 | { 15 | public GetElementTextCommand(string elementId, int id = 0, string commandName = "getElementText") : base(id, commandName) 16 | { 17 | ElementId = elementId; 18 | } 19 | 20 | public string ElementId { get; set; } 21 | 22 | public override void ProcessResponse(JToken response) 23 | { 24 | base.ProcessResponse(response); 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return JsonConvert.SerializeObject( 30 | new object[] 31 | { 32 | 0, 33 | Id, 34 | CommandName, 35 | new { 36 | id = ElementId, 37 | } 38 | 39 | }); 40 | 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetElementValueOfCssPropertyCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetElementValueOfCssPropertyCommand : MarionetteDebuggerCommand 14 | { 15 | public GetElementValueOfCssPropertyCommand(string elementId, string propName, int id = 0, string commandName = "getElementValueOfCssProperty") : base(id, commandName) 16 | { 17 | ElementId = elementId; 18 | PropertyName = propName; 19 | } 20 | public string ElementId { get; set; } 21 | public string PropertyName { get; set; } 22 | 23 | public override void ProcessResponse(JToken response) 24 | { 25 | base.ProcessResponse(response); 26 | } 27 | 28 | public override string ToString() 29 | { 30 | return JsonConvert.SerializeObject( 31 | new object[] 32 | { 33 | 0, 34 | Id, 35 | CommandName, 36 | new { 37 | id = ElementId, 38 | name = PropertyName 39 | } 40 | 41 | }); 42 | 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetPageSourceCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetPageSourceCommand : MarionetteDebuggerCommand 14 | { 15 | public GetPageSourceCommand(int id = 0, string commandName = "getPageSource") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | }); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetTextFromDialogCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetTextFromDialogCommand : MarionetteDebuggerCommand 14 | { 15 | public GetTextFromDialogCommand(int id = 0, string commandName = "getTextFromDialog") : base(id, commandName) 16 | { 17 | } 18 | public override void ProcessResponse(JToken response) 19 | { 20 | base.ProcessResponse(response); 21 | } 22 | 23 | public override string ToString() 24 | { 25 | return JsonConvert.SerializeObject( 26 | new object[] 27 | { 28 | 0, 29 | Id, 30 | CommandName, 31 | 32 | }); 33 | 34 | } 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetTimeoutsCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetTimeoutsCommand : MarionetteDebuggerCommand 14 | { 15 | public GetTimeoutsCommand(int id = 0, string commandName = "getTimeouts") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | }); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetTitleCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetTitleCommand : MarionetteDebuggerCommand 14 | { 15 | public GetTitleCommand(int id = 0, string commandName = "getTitle") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | }); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetWindowHandleCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetWindowHandleCommand : MarionetteDebuggerCommand 14 | { 15 | public GetWindowHandleCommand(int id = 0, string commandName = "getWindowHandle") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | }); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetWindowHandlesCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetWindowHandlesCommand : MarionetteDebuggerCommand 14 | { 15 | public GetWindowHandlesCommand(int id = 0, string commandName = "getWindowHandles") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | }); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetWindowPositionCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetWindowPositionCommand : MarionetteDebuggerCommand 14 | { 15 | public GetWindowPositionCommand(int id = 0, string commandName = "getWindowPosition") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | }); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetWindowSizeCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetWindowSizeCommand : MarionetteDebuggerCommand 14 | { 15 | public GetWindowSizeCommand(int id = 0, string commandName = "getWindowSize") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | }); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GetWindowTypeCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GetWindowTypeCommand : MarionetteDebuggerCommand 14 | { 15 | public GetWindowTypeCommand(int id = 0, string commandName = "getWindowType") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | }); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GoBackCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GoBackCommand : MarionetteDebuggerCommand 14 | { 15 | public GoBackCommand(int id = 0, string commandName = "goBack") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | 33 | }); 34 | 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/GoForwardCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class GoForwardCommand : MarionetteDebuggerCommand 14 | { 15 | public GoForwardCommand(int id = 0, string commandName = "goForward") : base(id, commandName) 16 | { 17 | } 18 | public override void ProcessResponse(JToken response) 19 | { 20 | base.ProcessResponse(response); 21 | } 22 | 23 | public override string ToString() 24 | { 25 | return JsonConvert.SerializeObject( 26 | new object[] 27 | { 28 | 0, 29 | Id, 30 | CommandName, 31 | 32 | }); 33 | 34 | } 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/ImportScriptCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class ImportScriptCommand : MarionetteDebuggerCommand 14 | { 15 | /** 16 | * Import script to the JS evaluation runtime. 17 | * 18 | * Imported scripts are exposed in the contexts of all subsequent 19 | * calls to {@code executeScript}, {@code executeAsyncScript}, and 20 | * {@code executeJSScript} by prepending them to the evaluated script. 21 | * 22 | * Scripts can be cleared with the {@code clearImportedScripts} command. 23 | * 24 | * @param {string} script 25 | * Script to include. If the script is byte-by-byte equal to an 26 | * existing imported script, it is not imported. 27 | */ 28 | public ImportScriptCommand(string script, int id = 0, string commandName = "importScript") : base(id, commandName) 29 | { 30 | Script = script; 31 | } 32 | 33 | public string Script { get; set; } 34 | 35 | public override void ProcessResponse(JToken response) 36 | { 37 | base.ProcessResponse(response); 38 | } 39 | 40 | public override string ToString() 41 | { 42 | return JsonConvert.SerializeObject( 43 | new object[] 44 | { 45 | 0, 46 | Id, 47 | CommandName, 48 | new { 49 | script = Script, 50 | } 51 | 52 | }); 53 | 54 | //return $"[0, {Id}, \"{CommandName}\", {{\"script\": \"{Script}\"}} ]"; 55 | 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/IsElementDisplayedCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class IsElementDisplayedCommand : MarionetteDebuggerCommand 14 | { 15 | public IsElementDisplayedCommand(string elementId, int id = 0, string commandName = "isElementDisplayed") : base(id, commandName) 16 | { 17 | ElementId = elementId; 18 | } 19 | 20 | public string ElementId { get; set; } 21 | 22 | public override void ProcessResponse(JToken response) 23 | { 24 | base.ProcessResponse(response); 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return JsonConvert.SerializeObject( 30 | new object[] 31 | { 32 | 0, 33 | Id, 34 | CommandName, 35 | new { 36 | id = ElementId, 37 | } 38 | 39 | }); 40 | 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/IsElementEnabledCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class IsElementEnabledCommand : MarionetteDebuggerCommand 14 | { 15 | public IsElementEnabledCommand(string elementId, int id = 0, string commandName = "isElementEnabled") : base(id, commandName) 16 | { 17 | ElementId = elementId; 18 | } 19 | 20 | public string ElementId { get; set; } 21 | 22 | public override void ProcessResponse(JToken response) 23 | { 24 | base.ProcessResponse(response); 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return JsonConvert.SerializeObject( 30 | new object[] 31 | { 32 | 0, 33 | Id, 34 | CommandName, 35 | new { 36 | id = ElementId, 37 | } 38 | 39 | }); 40 | 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/IsElementSelectedCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class IsElementSelectedCommand : MarionetteDebuggerCommand 14 | { 15 | public IsElementSelectedCommand(string elementId, int id = 0, string commandName = "isElementSelected") : base(id, commandName) 16 | { 17 | ElementId = elementId; 18 | } 19 | 20 | public string ElementId { get; set; } 21 | 22 | public override void ProcessResponse(JToken response) 23 | { 24 | base.ProcessResponse(response); 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return JsonConvert.SerializeObject( 30 | new object[] 31 | { 32 | 0, 33 | Id, 34 | CommandName, 35 | new { 36 | id = ElementId, 37 | } 38 | 39 | }); 40 | 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/MaximizeWindowCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class MaximizeWindowCommand : MarionetteDebuggerCommand 14 | { 15 | public MaximizeWindowCommand(int id = 0, string commandName = "maximizeWindow") : base(id, commandName) 16 | { 17 | } 18 | public override void ProcessResponse(JToken response) 19 | { 20 | base.ProcessResponse(response); 21 | } 22 | 23 | public override string ToString() 24 | { 25 | return JsonConvert.SerializeObject( 26 | new object[] 27 | { 28 | 0, 29 | Id, 30 | CommandName, 31 | 32 | }); 33 | 34 | } 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/NewSessionCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class NewSessionCommand : MarionetteDebuggerCommand 14 | { 15 | public NewSessionCommand(int id = 0, string commandName = "") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | "newSession", 32 | new { 33 | capabilities = new 34 | { 35 | desiredCapabilities = new 36 | { 37 | browserName = "firefox", 38 | marionette = true, 39 | platform = "ANY", 40 | version = "" 41 | }, 42 | requiredCapabilities = new 43 | { 44 | 45 | } 46 | }, 47 | //sessionId = null 48 | } 49 | 50 | }); 51 | 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/PerformActionsCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class PerformActionsCommand : MarionetteDebuggerCommand 14 | { 15 | public PerformActionsCommand(List actions, int id = 0, string commandName = "WebDriver:PerformActions") : base(id, commandName) 16 | { 17 | Actions = actions; 18 | } 19 | public List Actions { get; set; } 20 | public override void ProcessResponse(JToken response) 21 | { 22 | base.ProcessResponse(response); 23 | } 24 | 25 | public override string ToString() 26 | { 27 | return JsonConvert.SerializeObject( 28 | new object[] 29 | { 30 | 0, 31 | Id, 32 | CommandName, 33 | new { 34 | actions = Actions 35 | } 36 | 37 | }); 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/RefreshCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class RefreshCommand : MarionetteDebuggerCommand 14 | { 15 | public RefreshCommand(int id = 0, string commandName = "refresh") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | 33 | }); 34 | 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/ReleaseActionsCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class ReleaseActionsCommand : MarionetteDebuggerCommand 14 | { 15 | public ReleaseActionsCommand(int id = 0, string commandName = "WebDriver:ReleaseActions") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | 33 | }); 34 | 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/SendKeysToDialogCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class SendKeysToDialogCommand : MarionetteDebuggerCommand 14 | { 15 | public SendKeysToDialogCommand(string text, int id = 0, string commandName = "sendKeysToDialog") : base(id, commandName) 16 | { 17 | Text = text; 18 | } 19 | public string Text { get; set; } 20 | 21 | public override void ProcessResponse(JToken response) 22 | { 23 | base.ProcessResponse(response); 24 | } 25 | 26 | public override string ToString() 27 | { 28 | return JsonConvert.SerializeObject( 29 | new object[] 30 | { 31 | 0, 32 | Id, 33 | CommandName, 34 | new { 35 | text = Text 36 | } 37 | 38 | }); 39 | 40 | } 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/SendKeysToElementCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class SendKeysToElementCommand : MarionetteDebuggerCommand 14 | { 15 | public SendKeysToElementCommand(string elementId, string text, int id = 0, string commandName = "sendKeysToElement") : base(id, commandName) 16 | { 17 | ElementId = elementId; 18 | Text = text; 19 | } 20 | 21 | public string ElementId { get; set; } 22 | public string Text { get; set; } 23 | 24 | public override void ProcessResponse(JToken response) 25 | { 26 | base.ProcessResponse(response); 27 | } 28 | 29 | public override string ToString() 30 | { 31 | return JsonConvert.SerializeObject( 32 | new object[] 33 | { 34 | 0, 35 | Id, 36 | CommandName, 37 | new { 38 | id = ElementId, 39 | text = Text, 40 | //value = Text.ToArray() 41 | } 42 | 43 | }); 44 | 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/SessionTearDownCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class SessionTearDownCommand : MarionetteDebuggerCommand 14 | { 15 | public SessionTearDownCommand(int id = 0, string commandName = "sessionTearDown") : base(id, commandName) 16 | { 17 | } 18 | 19 | public override void ProcessResponse(JToken response) 20 | { 21 | base.ProcessResponse(response); 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return JsonConvert.SerializeObject( 27 | new object[] 28 | { 29 | 0, 30 | Id, 31 | CommandName, 32 | 33 | }); 34 | 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/SetContextCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class SetContextCommand : MarionetteDebuggerCommand 14 | { 15 | public enum Contexts { chrome, content }; 16 | public SetContextCommand(Contexts c, int id = 0, string commandName = "setContext") : base(id, commandName) 17 | { 18 | Context = c; 19 | } 20 | public Contexts Context { get; set; } 21 | 22 | public override void ProcessResponse(JToken response) 23 | { 24 | base.ProcessResponse(response); 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return JsonConvert.SerializeObject( 30 | new object[] 31 | { 32 | 0, 33 | Id, 34 | CommandName, 35 | new { 36 | value = GetContextStr() 37 | } 38 | 39 | }); 40 | 41 | } 42 | 43 | private string GetContextStr() 44 | { 45 | switch(Context) 46 | { 47 | case Contexts.content: return "content"; 48 | case Contexts.chrome: return "chrome"; 49 | } 50 | return null; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/SetTimeoutsCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using Zu.WebBrowser; 11 | 12 | namespace MyCommunicationLib.Communication.MarionetteComands 13 | { 14 | public class SetTimeoutsCommand : MarionetteDebuggerCommand 15 | { 16 | public enum TimeoutType { implicitWait, script, page_load }; 17 | public SetTimeoutsCommand(TimeoutType timeoutType, int ms, int id = 0, string commandName = "setTimeouts") : base(id, commandName) 18 | { 19 | Type = timeoutType; 20 | Ms = ms; 21 | } 22 | public TimeoutType Type { get; set; } 23 | public int Ms { get; set; } 24 | 25 | public override void ProcessResponse(JToken response) 26 | { 27 | base.ProcessResponse(response); 28 | } 29 | 30 | public override string ToString() 31 | { 32 | return $"[0, {Id}, \"{CommandName}\", {{\"{GetTimeoutTypeStr(Type)}\": {Ms}}} ]"; 33 | 34 | } 35 | 36 | public static string GetTimeoutTypeStr(TimeoutType t) 37 | { 38 | switch(t) 39 | { 40 | case TimeoutType.implicitWait: return "implicit"; 41 | case TimeoutType.script: return "script"; 42 | case TimeoutType.page_load: return "pageLoad"; //"page load"; // 43 | } 44 | return null; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/SetWindowPositionCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class SetWindowPositionCommand : MarionetteDebuggerCommand 14 | { 15 | public SetWindowPositionCommand(int x, int y, int id = 0, string commandName = "setWindowPosition") : base(id, commandName) 16 | { 17 | X = x; 18 | Y = y; 19 | } 20 | public int X { get; set; } 21 | public int Y { get; set; } 22 | public override void ProcessResponse(JToken response) 23 | { 24 | base.ProcessResponse(response); 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return JsonConvert.SerializeObject( 30 | new object[] 31 | { 32 | 0, 33 | Id, 34 | CommandName, 35 | new { 36 | x = X, 37 | y = Y 38 | } 39 | 40 | }); 41 | 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/SetWindowSizeCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class SetWindowSizeCommand : MarionetteDebuggerCommand 14 | { 15 | public SetWindowSizeCommand(int width, int height, int id = 0, string commandName = "setWindowSize") : base(id, commandName) 16 | { 17 | Width = width; 18 | Height = height; 19 | } 20 | public int Width { get; set; } 21 | public int Height { get; set; } 22 | public override void ProcessResponse(JToken response) 23 | { 24 | base.ProcessResponse(response); 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return JsonConvert.SerializeObject( 30 | new object[] 31 | { 32 | 0, 33 | Id, 34 | CommandName, 35 | new { 36 | width = Width, 37 | height = Height 38 | } 39 | 40 | }); 41 | 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/SwitchToParentFrameCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class SwitchToParentFrameCommand : MarionetteDebuggerCommand 14 | { 15 | public SwitchToParentFrameCommand(int id = 0, string commandName = "switchToParentFrame") : base(id, commandName) 16 | { 17 | } 18 | public override void ProcessResponse(JToken response) 19 | { 20 | base.ProcessResponse(response); 21 | } 22 | 23 | public override string ToString() 24 | { 25 | return JsonConvert.SerializeObject( 26 | new object[] 27 | { 28 | 0, 29 | Id, 30 | CommandName, 31 | }); 32 | 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/SwitchToWindowCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class SwitchToWindowCommand : MarionetteDebuggerCommand 14 | { 15 | public SwitchToWindowCommand(string name, int id = 0, string commandName = "switchToWindow") : base(id, commandName) 16 | { 17 | Name = name; 18 | } 19 | public string Name { get; set; } 20 | public override void ProcessResponse(JToken response) 21 | { 22 | base.ProcessResponse(response); 23 | } 24 | 25 | public override string ToString() 26 | { 27 | return JsonConvert.SerializeObject( 28 | new object[] 29 | { 30 | 0, 31 | Id, 32 | CommandName, 33 | new { 34 | name = Name 35 | } 36 | 37 | }); 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteComands/TakeScreenshotCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace MyCommunicationLib.Communication.MarionetteComands 12 | { 13 | public class TakeScreenshotCommand : MarionetteDebuggerCommand 14 | { 15 | public TakeScreenshotCommand(string elementId, string highlights, string full, string hash, int id = 0, string commandName = "takeScreenshot") : base(id, commandName) 16 | { 17 | ElementId = elementId; 18 | } 19 | public string ElementId { get; set; } 20 | 21 | public override void ProcessResponse(JToken response) 22 | { 23 | base.ProcessResponse(response); 24 | } 25 | 26 | public override string ToString() 27 | { 28 | return JsonConvert.SerializeObject( 29 | new object[] 30 | { 31 | 0, 32 | Id, 33 | CommandName, 34 | new { 35 | id = ElementId, 36 | } 37 | 38 | }); 39 | 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteDebuggerCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Newtonsoft.Json.Linq; 4 | using System.Linq; 5 | using Zu.WebBrowser.Commands; 6 | 7 | namespace MyCommunicationLib.Communication.MarionetteComands 8 | { 9 | public class MarionetteDebuggerCommand : DebuggerCommand 10 | { 11 | public MarionetteDebuggerCommand(int id, string commandName) : base(id, commandName) 12 | { 13 | } 14 | public JToken Result { get; set; } 15 | public JToken Error { get; set; } 16 | 17 | public override void ProcessResponse(JToken response) 18 | { 19 | base.ProcessResponse(response); 20 | Result = response; 21 | Error = (response?.Parent as JArray)?.ElementAtOrDefault(2); 22 | //if (Error?.HasValues != true) Error = null; 23 | if (Error is JValue && (Error as JValue).Value == null ) Error = null; 24 | } 25 | 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/MarionetteDebuggerCommandString.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | 4 | namespace MyCommunicationLib.Communication.MarionetteComands 5 | { 6 | public class MarionetteDebuggerCommandString : MarionetteDebuggerCommand 7 | { 8 | public MarionetteDebuggerCommandString(string commandStr, int id) : base(id, "") 9 | { 10 | CommandStr = commandStr; 11 | } 12 | 13 | public string CommandStr { get; set; } 14 | 15 | public override string ToString() 16 | { 17 | return CommandStr; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Общие сведения об этой сборке предоставляются следующим набором 6 | // набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, 7 | // связанные со сборкой. 8 | [assembly: AssemblyTitle("AsyncFirefoxDriver")] 9 | [assembly: AssemblyDescription("Async Firefox Driver connects directly to Marionette and is async from this connection. No need in geckodriver.exe. AsyncFirefoxDriver implements IAsyncWebBrowserClient interfaces and can be used as AsyncWebDriver.")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Oleg Zudov")] 12 | [assembly: AssemblyProduct("AsyncFirefoxDriver")] 13 | [assembly: AssemblyCopyright("Copyright © Oleg Zudov 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми 18 | // для компонентов COM. Если необходимо обратиться к типу в этой сборке через 19 | // COM, задайте атрибуту ComVisible значение TRUE для этого типа. 20 | [assembly: ComVisible(false)] 21 | 22 | // Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM 23 | [assembly: Guid("13891dba-94c7-45aa-b9bd-77ac7b56c379")] 24 | 25 | // Сведения о версии сборки состоят из следующих четырех значений: 26 | // 27 | // Основной номер версии 28 | // Дополнительный номер версии 29 | // Номер сборки 30 | // Редакция 31 | // 32 | // Можно задать все значения или принять номер сборки и номер редакции по умолчанию. 33 | // используя "*", как показано ниже: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.3.12.0")] 36 | [assembly: AssemblyFileVersion("1.3.12.0")] 37 | -------------------------------------------------------------------------------- /AsyncFirefoxDriver/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /AsyncFirefoxDriverExample/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /AsyncFirefoxDriverExample/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AsyncFirefoxDriverExample/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace AsyncFirefoxDriverExample 10 | { 11 | /// 12 | /// Логика взаимодействия для App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /AsyncFirefoxDriverExample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // Общие сведения об этой сборке предоставляются следующим набором 8 | // набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, 9 | // связанные со сборкой. 10 | [assembly: AssemblyTitle("AsyncFirefoxDriverExample")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("AsyncFirefoxDriverExample")] 15 | [assembly: AssemblyCopyright("Copyright © 2017")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми 20 | // для компонентов COM. Если необходимо обратиться к типу в этой сборке через 21 | // COM, задайте атрибуту ComVisible значение TRUE для этого типа. 22 | [assembly: ComVisible(false)] 23 | 24 | //Чтобы начать создание локализуемых приложений, задайте 25 | //CultureYouAreCodingWith в файле .csproj 26 | //внутри . Например, если используется английский США 27 | //в своих исходных файлах установите в en-US. Затем отмените преобразование в комментарий 28 | //атрибута NeutralResourceLanguage ниже. Обновите "en-US" в 29 | //строка внизу для обеспечения соответствия настройки UICulture в файле проекта. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //где расположены словари ресурсов по конкретным тематикам 36 | //(используется, если ресурс не найден на странице, 37 | // или в словарях ресурсов приложения) 38 | ResourceDictionaryLocation.SourceAssembly //где расположен словарь универсальных ресурсов 39 | //(используется, если ресурс не найден на странице, 40 | // в приложении или в каких-либо словарях ресурсов для конкретной темы) 41 | )] 42 | 43 | 44 | // Сведения о версии сборки состоят из следующих четырех значений: 45 | // 46 | // Основной номер версии 47 | // Дополнительный номер версии 48 | // Номер сборки 49 | // Редакция 50 | // 51 | // Можно задать все значения или принять номер сборки и номер редакции по умолчанию. 52 | // используя "*", как показано ниже: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.1.0")] 55 | [assembly: AssemblyFileVersion("1.0.1.0")] 56 | -------------------------------------------------------------------------------- /AsyncFirefoxDriverExample/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Этот код создан программой. 4 | // Исполняемая версия:4.0.30319.42000 5 | // 6 | // Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае 7 | // повторной генерации кода. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace AsyncFirefoxDriverExample.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /AsyncFirefoxDriverExample/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /AsyncFirefoxDriverExample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /AsyncWebDriver/AsyncWebDriver.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0;net462 5 | 1.4.6 6 | IAsyncWebBrowserClient update 7 | Async WebDriver is base for different WebBrowser drivers 8 | Oleg Zudov 9 | Copyright Oleg Zudov 2018 10 | 11 | https://github.com/ToCSharp/IAsyncWebBrowserClient 12 | https://github.com/ToCSharp/IAsyncWebBrowserClient 13 | WebDriver Browser AsyncWebDriver 14 | true 15 | LICENSE.txt 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | True 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /AsyncWebDriver/AsyncWebDriver.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $title$ 7 | $author$ 8 | $author$ 9 | https://github.com/ToCSharp/AsyncWebDriver/blob/master/LICENSE.txt 10 | https://github.com/ToCSharp/AsyncWebDriver 11 | false 12 | $description$ 13 | Async WebDriver is base for different WebBrowser drivers 14 | TaskWebSizeWebPointExtensions: Task_WebSize and Task_WebPoint extensions 15 | Copyright Oleg Zudov 2018 16 | WebDriver Browser 17 | 18 | -------------------------------------------------------------------------------- /AsyncWebDriver/AsyncWebDriver/TaskExt.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | using System; 3 | using System.Threading.Tasks; 4 | 5 | namespace Zu.AsyncWebDriver.Remote 6 | { 7 | public static class TaskExt 8 | { 9 | public static async Task TimeoutAfter(this Task task, int timeout) 10 | { 11 | //var timeoutCancellationTokenSource = new CancellationTokenSource(); 12 | var completedTask = await Task.WhenAny(task, Task.Delay(timeout /*, timeoutCancellationTokenSource.Token*/)).ConfigureAwait(false); 13 | if (completedTask == task) 14 | { 15 | //timeoutCancellationTokenSource.Cancel(); 16 | return await task.ConfigureAwait(false); 17 | } 18 | 19 | throw new TimeoutException("The operation has timed out."); 20 | } 21 | 22 | public static async Task TimeoutAfter(this Task task, int timeout) 23 | { 24 | //var timeoutCancellationTokenSource = new CancellationTokenSource(); 25 | var completedTask = await Task.WhenAny(task, Task.Delay(timeout /*, timeoutCancellationTokenSource.Token*/)).ConfigureAwait(false); 26 | if (completedTask == task) 27 | { 28 | await task.ConfigureAwait(false); 29 | return; 30 | } 31 | 32 | throw new TimeoutException("The operation has timed out."); 33 | } 34 | //todo. It not working 35 | //public static TResult DoSync(this Task task) 36 | //{ 37 | // var res = default(TResult); 38 | // var mRes = new ManualResetEventSlim(true); 39 | // mRes.Reset(); 40 | // Task.Run(async () => 41 | // { 42 | // res = await task; 43 | // mRes.Set(); 44 | // } 45 | // ); 46 | // mRes.Wait(); 47 | // return res; 48 | //} 49 | //todo. It not working 50 | //public static void DoSync(this Task task) 51 | //{ 52 | // var mRes = new ManualResetEventSlim(true); 53 | // mRes.Reset(); 54 | // Task.Run(async () => 55 | // { 56 | // await task; 57 | // mRes.Set(); 58 | // } 59 | // ); 60 | // mRes.Wait(); 61 | //} 62 | } 63 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Exceptions/ElementNotSelectableException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using System; 5 | using System.Runtime.Serialization; 6 | 7 | namespace Zu.AsyncWebDriver 8 | { 9 | /// 10 | /// The exception that is thrown when an element is not visible. 11 | /// 12 | [Serializable] 13 | public class ElementNotSelectableException : InvalidElementStateException 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public ElementNotSelectableException() 19 | : base() 20 | { 21 | } 22 | 23 | /// 24 | /// Initializes a new instance of the class with 25 | /// a specified error message. 26 | /// 27 | /// The message that describes the error. 28 | public ElementNotSelectableException(string message) 29 | : base(message) 30 | { 31 | } 32 | 33 | /// 34 | /// Initializes a new instance of the class with 35 | /// a specified error message and a reference to the inner exception that is the 36 | /// cause of this exception. 37 | /// 38 | /// The error message that explains the reason for the exception. 39 | /// The exception that is the cause of the current exception, 40 | /// or if no inner exception is specified. 41 | public ElementNotSelectableException(string message, Exception innerException) 42 | : base(message, innerException) 43 | { 44 | } 45 | 46 | /// 47 | /// Initializes a new instance of the class with serialized data. 48 | /// 49 | /// The that holds the serialized 50 | /// object data about the exception being thrown. 51 | /// The that contains contextual 52 | /// information about the source or destination. 53 | protected ElementNotSelectableException(SerializationInfo info, StreamingContext context) 54 | : base(info, context) 55 | { 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /AsyncWebDriver/Exceptions/ElementNotVisibleException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using System; 5 | using System.Runtime.Serialization; 6 | 7 | namespace Zu.AsyncWebDriver 8 | { 9 | /// 10 | /// The exception that is thrown when an element is not visible. 11 | /// 12 | [Serializable] 13 | public class ElementNotVisibleException : ElementNotInteractableException 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public ElementNotVisibleException() 19 | : base() 20 | { 21 | } 22 | 23 | /// 24 | /// Initializes a new instance of the class with 25 | /// a specified error message. 26 | /// 27 | /// The message that describes the error. 28 | public ElementNotVisibleException(string message) 29 | : base(message) 30 | { 31 | } 32 | 33 | /// 34 | /// Initializes a new instance of the class with 35 | /// a specified error message and a reference to the inner exception that is the 36 | /// cause of this exception. 37 | /// 38 | /// The error message that explains the reason for the exception. 39 | /// The exception that is the cause of the current exception, 40 | /// or if no inner exception is specified. 41 | public ElementNotVisibleException(string message, Exception innerException) 42 | : base(message, innerException) 43 | { 44 | } 45 | 46 | /// 47 | /// Initializes a new instance of the class with serialized data. 48 | /// 49 | /// The that holds the serialized 50 | /// object data about the exception being thrown. 51 | /// The that contains contextual 52 | /// information about the source or destination. 53 | protected ElementNotVisibleException(SerializationInfo info, StreamingContext context) 54 | : base(info, context) 55 | { 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /AsyncWebDriver/Exceptions/InvalidElementStateException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using System; 5 | using System.Runtime.Serialization; 6 | 7 | namespace Zu.AsyncWebDriver 8 | { 9 | /// 10 | /// The exception that is thrown when a reference to an element is no longer valid. 11 | /// 12 | [Serializable] 13 | public class InvalidElementStateException : WebDriverException 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public InvalidElementStateException() 19 | : base() 20 | { 21 | } 22 | 23 | /// 24 | /// Initializes a new instance of the class with 25 | /// a specified error message. 26 | /// 27 | /// The message that describes the error. 28 | public InvalidElementStateException(string message) 29 | : base(message) 30 | { 31 | } 32 | 33 | /// 34 | /// Initializes a new instance of the class with 35 | /// a specified error message and a reference to the inner exception that is the 36 | /// cause of this exception. 37 | /// 38 | /// The error message that explains the reason for the exception. 39 | /// The exception that is the cause of the current exception, 40 | /// or if no inner exception is specified. 41 | public InvalidElementStateException(string message, Exception innerException) 42 | : base(message, innerException) 43 | { 44 | } 45 | 46 | /// 47 | /// Initializes a new instance of the class with serialized data. 48 | /// 49 | /// The that holds the serialized 50 | /// object data about the exception being thrown. 51 | /// The that contains contextual 52 | /// information about the source or destination. 53 | protected InvalidElementStateException(SerializationInfo info, StreamingContext context) 54 | : base(info, context) 55 | { 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /AsyncWebDriver/Exceptions/NoAlertPresentException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using System; 5 | using System.Runtime.Serialization; 6 | 7 | namespace Zu.AsyncWebDriver 8 | { 9 | /// 10 | /// The exception that is thrown when an alert is not found. 11 | /// 12 | [Serializable] 13 | public class NoAlertPresentException : NotFoundException 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public NoAlertPresentException() 19 | : base() 20 | { 21 | } 22 | 23 | /// 24 | /// Initializes a new instance of the class with 25 | /// a specified error message. 26 | /// 27 | /// The message that describes the error. 28 | public NoAlertPresentException(string message) 29 | : base(message) 30 | { 31 | } 32 | 33 | /// 34 | /// Initializes a new instance of the class with 35 | /// a specified error message and a reference to the inner exception that is the 36 | /// cause of this exception. 37 | /// 38 | /// The error message that explains the reason for the exception. 39 | /// The exception that is the cause of the current exception, 40 | /// or if no inner exception is specified. 41 | public NoAlertPresentException(string message, Exception innerException) 42 | : base(message, innerException) 43 | { 44 | } 45 | 46 | /// 47 | /// Initializes a new instance of the class with serialized data. 48 | /// 49 | /// The that holds the serialized 50 | /// object data about the exception being thrown. 51 | /// The that contains contextual 52 | /// information about the source or destination. 53 | protected NoAlertPresentException(SerializationInfo info, StreamingContext context) 54 | : base(info, context) 55 | { 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /AsyncWebDriver/Exceptions/NoSuchElementException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using System; 5 | using System.Runtime.Serialization; 6 | 7 | namespace Zu.AsyncWebDriver 8 | { 9 | /// 10 | /// The exception that is thrown when an element is not found. 11 | /// 12 | [Serializable] 13 | public class NoSuchElementException : NotFoundException 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public NoSuchElementException() 19 | { 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of the class with 24 | /// a specified error message. 25 | /// 26 | /// The message that describes the error. 27 | public NoSuchElementException(string message) : base(message) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class with 33 | /// a specified error message and a reference to the inner exception that is the 34 | /// cause of this exception. 35 | /// 36 | /// The error message that explains the reason for the exception. 37 | /// 38 | /// The exception that is the cause of the current exception, 39 | /// or if no inner exception is specified. 40 | /// 41 | public NoSuchElementException(string message, Exception innerException) : base(message, innerException) 42 | { 43 | } 44 | 45 | /// 46 | /// Initializes a new instance of the class with serialized data. 47 | /// 48 | /// 49 | /// The that holds the serialized 50 | /// object data about the exception being thrown. 51 | /// 52 | /// 53 | /// The that contains contextual 54 | /// information about the source or destination. 55 | /// 56 | protected NoSuchElementException(SerializationInfo info, StreamingContext context) : base(info, context) 57 | { 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Exceptions/NoSuchFrameException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using System; 5 | using System.Runtime.Serialization; 6 | 7 | namespace Zu.AsyncWebDriver 8 | { 9 | /// 10 | /// The exception that is thrown when a frame is not found. 11 | /// 12 | [Serializable] 13 | public class NoSuchFrameException : NotFoundException 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public NoSuchFrameException() 19 | { 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of the class with 24 | /// a specified error message. 25 | /// 26 | /// The message that describes the error. 27 | public NoSuchFrameException(string message) : base(message) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class with 33 | /// a specified error message and a reference to the inner exception that is the 34 | /// cause of this exception. 35 | /// 36 | /// The error message that explains the reason for the exception. 37 | /// 38 | /// The exception that is the cause of the current exception, 39 | /// or if no inner exception is specified. 40 | /// 41 | public NoSuchFrameException(string message, Exception innerException) : base(message, innerException) 42 | { 43 | } 44 | 45 | /// 46 | /// Initializes a new instance of the class with serialized data. 47 | /// 48 | /// 49 | /// The that holds the serialized 50 | /// object data about the exception being thrown. 51 | /// 52 | /// 53 | /// The that contains contextual 54 | /// information about the source or destination. 55 | /// 56 | protected NoSuchFrameException(SerializationInfo info, StreamingContext context) : base(info, context) 57 | { 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Exceptions/NoSuchWindowException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using System; 5 | using System.Runtime.Serialization; 6 | 7 | namespace Zu.AsyncWebDriver 8 | { 9 | /// 10 | /// The exception that is thrown when a window is not found. 11 | /// 12 | [Serializable] 13 | public class NoSuchWindowException : NotFoundException 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public NoSuchWindowException() 19 | { 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of the class with 24 | /// a specified error message. 25 | /// 26 | /// The message that describes the error. 27 | public NoSuchWindowException(string message) : base(message) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class with 33 | /// a specified error message and a reference to the inner exception that is the 34 | /// cause of this exception. 35 | /// 36 | /// The error message that explains the reason for the exception. 37 | /// 38 | /// The exception that is the cause of the current exception, 39 | /// or if no inner exception is specified. 40 | /// 41 | public NoSuchWindowException(string message, Exception innerException) : base(message, innerException) 42 | { 43 | } 44 | 45 | /// 46 | /// Initializes a new instance of the class with serialized data. 47 | /// 48 | /// 49 | /// The that holds the serialized 50 | /// object data about the exception being thrown. 51 | /// 52 | /// 53 | /// The that contains contextual 54 | /// information about the source or destination. 55 | /// 56 | protected NoSuchWindowException(SerializationInfo info, StreamingContext context) : base(info, context) 57 | { 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Exceptions/NotFoundException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using System; 5 | using System.Runtime.Serialization; 6 | 7 | namespace Zu.AsyncWebDriver 8 | { 9 | /// 10 | /// The exception that is thrown when an item is not found. 11 | /// 12 | [Serializable] 13 | public class NotFoundException : WebDriverException 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public NotFoundException() 19 | { 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of the class with 24 | /// a specified error message. 25 | /// 26 | /// The message that describes the error. 27 | public NotFoundException(string message) : base(message) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class with 33 | /// a specified error message and a reference to the inner exception that is the 34 | /// cause of this exception. 35 | /// 36 | /// The error message that explains the reason for the exception. 37 | /// 38 | /// The exception that is the cause of the current exception, 39 | /// or if no inner exception is specified. 40 | /// 41 | public NotFoundException(string message, Exception innerException) : base(message, innerException) 42 | { 43 | } 44 | 45 | /// 46 | /// Initializes a new instance of the class with serialized data. 47 | /// 48 | /// 49 | /// The that holds the serialized 50 | /// object data about the exception being thrown. 51 | /// 52 | /// 53 | /// The that contains contextual 54 | /// information about the source or destination. 55 | /// 56 | protected NotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) 57 | { 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Exceptions/WebDriverException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using System; 5 | using System.Runtime.Serialization; 6 | 7 | namespace Zu.AsyncWebDriver 8 | { 9 | /// 10 | /// Represents exceptions that are thrown when an error occurs during actions. 11 | /// 12 | [Serializable] 13 | public class WebDriverException : Exception 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public WebDriverException() 19 | { 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of the class with 24 | /// a specified error message. 25 | /// 26 | /// The message that describes the error. 27 | public WebDriverException(string message) : base(message) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class with 33 | /// a specified error message and a reference to the inner exception that is the 34 | /// cause of this exception. 35 | /// 36 | /// The error message that explains the reason for the exception. 37 | /// 38 | /// The exception that is the cause of the current exception, 39 | /// or if no inner exception is specified. 40 | /// 41 | public WebDriverException(string message, Exception innerException) : base(message, innerException) 42 | { 43 | } 44 | 45 | /// 46 | /// Initializes a new instance of the class with serialized data. 47 | /// 48 | /// 49 | /// The that holds the serialized 50 | /// object data about the exception being thrown. 51 | /// 52 | /// 53 | /// The that contains contextual 54 | /// information about the source or destination. 55 | /// 56 | protected WebDriverException(SerializationInfo info, StreamingContext context) : base(info, context) 57 | { 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Exceptions/WebDriverTimeoutException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using System; 5 | using System.Runtime.Serialization; 6 | 7 | namespace Zu.AsyncWebDriver 8 | { 9 | /// 10 | /// Represents exceptions that are thrown when an error occurs during actions. 11 | /// 12 | [Serializable] 13 | public class WebDriverTimeoutException : WebDriverException 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public WebDriverTimeoutException() 19 | : base() 20 | { 21 | } 22 | 23 | /// 24 | /// Initializes a new instance of the class with 25 | /// a specified error message. 26 | /// 27 | /// The message that describes the error. 28 | public WebDriverTimeoutException(string message) 29 | : base(message) 30 | { 31 | } 32 | 33 | /// 34 | /// Initializes a new instance of the class with 35 | /// a specified error message and a reference to the inner exception that is the 36 | /// cause of this exception. 37 | /// 38 | /// The error message that explains the reason for the exception. 39 | /// The exception that is the cause of the current exception, 40 | /// or if no inner exception is specified. 41 | public WebDriverTimeoutException(string message, Exception innerException) 42 | : base(message, innerException) 43 | { 44 | } 45 | 46 | /// 47 | /// Initializes a new instance of the class with serialized data. 48 | /// 49 | /// The that holds the serialized 50 | /// object data about the exception being thrown. 51 | /// The that contains contextual 52 | /// information about the source or destination. 53 | protected WebDriverTimeoutException(SerializationInfo info, StreamingContext context) 54 | : base(info, context) 55 | { 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /AsyncWebDriver/Extensions/TaskISearchContextExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using System.Collections.ObjectModel; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace Zu.AsyncWebDriver 9 | { 10 | public static class TaskISearchContextExtensions 11 | { 12 | public static async Task FindElement(this Task elementTask, By by, 13 | CancellationToken cancellationToken = new CancellationToken()) 14 | { 15 | var el = await elementTask.ConfigureAwait(false); 16 | return await el.FindElement(by, cancellationToken).ConfigureAwait(false); 17 | } 18 | 19 | public static async Task> FindElements(this Task elementTask, By by, 20 | CancellationToken cancellationToken = new CancellationToken()) 21 | { 22 | var el = await elementTask.ConfigureAwait(false); 23 | return await el.FindElements(by, cancellationToken).ConfigureAwait(false); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Extensions/TaskWebSizeWebPointExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using System.Threading.Tasks; 5 | using Zu.WebBrowser.BasicTypes; 6 | 7 | namespace Zu.AsyncWebDriver 8 | { 9 | public static class TaskWebSizeWebPointExtensions 10 | { 11 | public static async Task Width(this Task elementTask) 12 | { 13 | var el = await elementTask.ConfigureAwait(false); 14 | return el.Width; 15 | } 16 | public static async Task Height(this Task elementTask) 17 | { 18 | var el = await elementTask.ConfigureAwait(false); 19 | return el.Height; 20 | } 21 | 22 | public static async Task X(this Task elementTask) 23 | { 24 | var el = await elementTask.ConfigureAwait(false); 25 | return el.X; 26 | } 27 | public static async Task Y(this Task elementTask) 28 | { 29 | var el = await elementTask.ConfigureAwait(false); 30 | return el.Y; 31 | } 32 | public static async Task Offset(this Task elementTask, int x, int y) 33 | { 34 | var el = await elementTask.ConfigureAwait(false); 35 | return el.Offset(x, y); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /AsyncWebDriver/IHasInputDevices.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using Zu.WebBrowser.AsyncInteractions; 5 | 6 | namespace Zu.AsyncWebDriver 7 | { 8 | /// 9 | /// Provides access to input devices for advanced user interactions. 10 | /// 11 | public interface IHasInputDevices 12 | { 13 | /// 14 | /// Gets an object for sending keystrokes to the browser. 15 | /// 16 | IKeyboard Keyboard { get; } 17 | 18 | /// 19 | /// Gets an object for sending mouse commands to the browser. 20 | /// 21 | IMouse Mouse { get; } 22 | } 23 | } -------------------------------------------------------------------------------- /AsyncWebDriver/IHasTouchScreen.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using Zu.WebBrowser.AsyncInteractions; 5 | 6 | namespace Zu.AsyncWebDriver 7 | { 8 | /// 9 | /// Interface implemented by each driver that allows access to touch screen capabilities. 10 | /// 11 | public interface IHasTouchScreen 12 | { 13 | /// 14 | /// Gets the device representing the touch screen. 15 | /// 16 | ITouchScreen TouchScreen { get; } 17 | } 18 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/BuiltAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.WebBrowser.AsyncInteractions; 6 | 7 | namespace Zu.AsyncWebDriver.Interactions 8 | { 9 | public class BuiltAction : IAction 10 | { 11 | private IWebDriver driver; 12 | private ActionBuilder actionBuilder; 13 | private CompositeAction action; 14 | public BuiltAction(IWebDriver driver, ActionBuilder actionBuilder, CompositeAction action) 15 | { 16 | this.driver = driver; 17 | this.actionBuilder = actionBuilder; 18 | this.action = action; 19 | } 20 | 21 | public async Task Perform(CancellationToken cancellationToken = default (CancellationToken)) 22 | { 23 | IActionExecutor actionExecutor = this.driver as IActionExecutor; 24 | if (await actionExecutor.IsActionExecutor(cancellationToken).ConfigureAwait(false)) 25 | { 26 | await actionExecutor.PerformActions(this.actionBuilder.ToActionSequenceList()).ConfigureAwait(false); 27 | } 28 | else 29 | { 30 | await this.action.Perform().ConfigureAwait(false); 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/ButtonReleaseAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.AsyncWebDriver.Interactions.Internal; 6 | using Zu.WebBrowser.AsyncInteractions; 7 | 8 | namespace Zu.AsyncWebDriver.Interactions 9 | { 10 | /// 11 | /// Defines an action for releasing the currently held mouse button. 12 | /// 13 | /// 14 | /// This action can be called for an element different than the one 15 | /// ClickAndHoldAction was called for. However, if this action is 16 | /// performed out of sequence (without holding down the mouse button, 17 | /// for example) the results will be different. 18 | /// 19 | public class ButtonReleaseAction : MouseAction, IAction 20 | { 21 | /// 22 | /// Initializes a new instance of the class. 23 | /// 24 | /// The with which the action will be performed. 25 | /// An describing an element at which to perform the action. 26 | public ButtonReleaseAction(IMouse mouse, ILocatable actionTarget): base (mouse, actionTarget) 27 | { 28 | } 29 | 30 | /// 31 | /// Performs this action. 32 | /// 33 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 34 | { 35 | // between browsers. 36 | await MoveToLocation(cancellationToken).ConfigureAwait(false); 37 | await Mouse.MouseUp(ActionLocation, cancellationToken).ConfigureAwait(false); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/ClickAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.AsyncWebDriver.Interactions.Internal; 6 | using Zu.WebBrowser.AsyncInteractions; 7 | 8 | namespace Zu.AsyncWebDriver.Interactions 9 | { 10 | /// 11 | /// Defines an action for clicking on an element. 12 | /// 13 | public class ClickAction : MouseAction, IAction 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The with which the action will be performed. 19 | /// An describing an element at which to perform the action. 20 | public ClickAction(IMouse mouse, ILocatable actionTarget): base (mouse, actionTarget) 21 | { 22 | } 23 | 24 | /// 25 | /// Performs this action. 26 | /// 27 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 28 | { 29 | await MoveToLocation(cancellationToken).ConfigureAwait(false); 30 | await Mouse.Click(ActionLocation, cancellationToken).ConfigureAwait(false); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/ClickAndHoldAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.AsyncWebDriver.Interactions.Internal; 6 | using Zu.WebBrowser.AsyncInteractions; 7 | 8 | namespace Zu.AsyncWebDriver.Interactions 9 | { 10 | /// 11 | /// Defines an action for clicking and holding the mouse button on an element. 12 | /// 13 | public class ClickAndHoldAction : MouseAction, IAction 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The with which the action will be performed. 19 | /// An describing an element at which to perform the action. 20 | public ClickAndHoldAction(IMouse mouse, ILocatable actionTarget): base (mouse, actionTarget) 21 | { 22 | } 23 | 24 | /// 25 | /// Performs this action. 26 | /// 27 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 28 | { 29 | await MoveToLocation(cancellationToken).ConfigureAwait(false); 30 | await Mouse.MouseDown(ActionLocation, cancellationToken).ConfigureAwait(false); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/CompositeAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Collections.Generic; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Zu.WebBrowser.AsyncInteractions; 7 | 8 | namespace Zu.AsyncWebDriver.Interactions 9 | { 10 | /// 11 | /// Defines an action that consists of a list of other actions to be performed in the browser. 12 | /// 13 | public class CompositeAction : IAction 14 | { 15 | private readonly List actionsList = new List(); 16 | /// 17 | /// Performs the actions defined in this list of actions. 18 | /// 19 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 20 | { 21 | foreach (var action in actionsList) 22 | await action.Perform(cancellationToken).ConfigureAwait(false); 23 | } 24 | 25 | /// 26 | /// Adds an action to the list of actions to be performed. 27 | /// 28 | /// 29 | /// An to be appended to the 30 | /// list of actions to be performed. 31 | /// 32 | /// A self reference. 33 | public CompositeAction AddAction(IAction action) 34 | { 35 | actionsList.Add(action); 36 | return this; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/ContextClickAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.AsyncWebDriver.Interactions.Internal; 6 | using Zu.WebBrowser.AsyncInteractions; 7 | 8 | namespace Zu.AsyncWebDriver.Interactions 9 | { 10 | /// 11 | /// Defines an action for clicking the secondary mouse button on an element, displaying a context menu. 12 | /// 13 | public class ContextClickAction : MouseAction, IAction 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The with which the action will be performed. 19 | /// An describing an element at which to perform the action. 20 | public ContextClickAction(IMouse mouse, ILocatable actionTarget): base (mouse, actionTarget) 21 | { 22 | } 23 | 24 | /// 25 | /// Performs this action. 26 | /// 27 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 28 | { 29 | await MoveToLocation(cancellationToken).ConfigureAwait(false); 30 | await Mouse.ContextClick(ActionLocation, cancellationToken).ConfigureAwait(false); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/DoubleClickAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.AsyncWebDriver.Interactions.Internal; 6 | using Zu.WebBrowser.AsyncInteractions; 7 | 8 | namespace Zu.AsyncWebDriver.Interactions 9 | { 10 | /// 11 | /// Defines an action for double-clicking on an element. 12 | /// 13 | public class DoubleClickAction : MouseAction, IAction 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The with which the action will be performed. 19 | /// An describing an element at which to perform the action. 20 | public DoubleClickAction(IMouse mouse, ILocatable actionTarget): base (mouse, actionTarget) 21 | { 22 | } 23 | 24 | /// 25 | /// Performs this action. 26 | /// 27 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 28 | { 29 | await MoveToLocation(cancellationToken).ConfigureAwait(false); 30 | await Mouse.DoubleClick(ActionLocation, cancellationToken).ConfigureAwait(false); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/DoubleTapAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Zu.AsyncWebDriver.Interactions.Internal; 7 | using Zu.WebBrowser.AsyncInteractions; 8 | 9 | namespace Zu.AsyncWebDriver.Interactions 10 | { 11 | /// 12 | /// Creates a double tap gesture on a touch screen. 13 | /// 14 | public class DoubleTapAction : TouchAction, IAction 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The with which the action will be performed. 20 | /// An describing an element at which to perform the action. 21 | public DoubleTapAction(ITouchScreen touchScreen, ILocatable actionTarget): base (touchScreen, actionTarget) 22 | { 23 | if (actionTarget == null) 24 | throw new ArgumentException("Must provide a location for a single tap action.", "actionTarget"); 25 | } 26 | 27 | /// 28 | /// Performs the action. 29 | /// 30 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 31 | { 32 | await TouchScreen.DoubleTap(ActionLocation, cancellationToken).ConfigureAwait(false); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/KeyDownAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.AsyncWebDriver.Interactions.Internal; 6 | using Zu.WebBrowser.AsyncInteractions; 7 | 8 | namespace Zu.AsyncWebDriver.Interactions 9 | { 10 | /// 11 | /// Defines an action for pressing a modifier key (Shift, Alt, or Control) on the keyboard. 12 | /// 13 | public class KeyDownAction : SingleKeyAction, IAction 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The to use in performing the action. 19 | /// The to use in setting focus to the element on which to perform the action. 20 | /// An object providing the element on which to perform the action. 21 | /// 22 | /// The modifier key (, , ) to 23 | /// use in the action. 24 | /// 25 | public KeyDownAction(IKeyboard keyboard, IMouse mouse, ILocatable actionTarget, string key): base (keyboard, mouse, actionTarget, key) 26 | { 27 | } 28 | 29 | /// 30 | /// Performs this action. 31 | /// 32 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 33 | { 34 | await FocusOnElement(cancellationToken).ConfigureAwait(false); 35 | await Keyboard.PressKey(Key, cancellationToken).ConfigureAwait(false); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/KeyUpAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.AsyncWebDriver.Interactions.Internal; 6 | using Zu.WebBrowser.AsyncInteractions; 7 | 8 | namespace Zu.AsyncWebDriver.Interactions 9 | { 10 | /// 11 | /// Defines an action for releasing a modifier key (Shift, Alt, or Control) on the keyboard. 12 | /// 13 | public class KeyUpAction : SingleKeyAction, IAction 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The to use in performing the action. 19 | /// The to use in setting focus to the element on which to perform the action. 20 | /// An object providing the element on which to perform the action. 21 | /// 22 | /// The modifier key (, , ) to 23 | /// use in the action. 24 | /// 25 | public KeyUpAction(IKeyboard keyboard, IMouse mouse, ILocatable actionTarget, string key): base (keyboard, mouse, actionTarget, key) 26 | { 27 | } 28 | 29 | /// 30 | /// Performs this action. 31 | /// 32 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 33 | { 34 | await FocusOnElement(cancellationToken).ConfigureAwait(false); 35 | await Keyboard.ReleaseKey(Key, cancellationToken).ConfigureAwait(false); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/KeyboardAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.WebBrowser.AsyncInteractions; 6 | 7 | namespace Zu.AsyncWebDriver.Interactions.Internal 8 | { 9 | /// 10 | /// Defines an action for keyboard interaction with the browser. 11 | /// 12 | public class KeyboardAction : WebDriverAction 13 | { 14 | private readonly IMouse mouse; 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The to use in performing the action. 19 | /// The to use in setting focus to the element on which to perform the action. 20 | /// An object providing the element on which to perform the action. 21 | protected KeyboardAction(IKeyboard keyboard, IMouse mouse, ILocatable actionTarget): base (actionTarget) 22 | { 23 | Keyboard = keyboard; 24 | this.mouse = mouse; 25 | } 26 | 27 | /// 28 | /// Gets the keyboard with which to perform the action. 29 | /// 30 | protected IKeyboard Keyboard 31 | { 32 | get; 33 | } 34 | 35 | /// 36 | /// Focuses on the element on which the action is to be performed. 37 | /// 38 | protected async Task FocusOnElement(CancellationToken cancellationToken = new CancellationToken()) 39 | { 40 | if (ActionTarget != null) 41 | await mouse.Click(ActionTarget.Coordinates, cancellationToken).ConfigureAwait(false); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/LongPressAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Zu.AsyncWebDriver.Interactions.Internal; 7 | using Zu.WebBrowser.AsyncInteractions; 8 | 9 | namespace Zu.AsyncWebDriver.Interactions 10 | { 11 | /// 12 | /// Creates a long press gesture on a touch screen. 13 | /// 14 | public class LongPressAction : TouchAction, IAction 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The with which the action will be performed. 20 | /// An describing an element at which to perform the action. 21 | public LongPressAction(ITouchScreen touchScreen, ILocatable actionTarget): base (touchScreen, actionTarget) 22 | { 23 | if (actionTarget == null) 24 | throw new ArgumentException("Must provide a location for a single tap action.", "actionTarget"); 25 | } 26 | 27 | /// 28 | /// Performs the action. 29 | /// 30 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 31 | { 32 | await TouchScreen.LongPress(ActionLocation, cancellationToken).ConfigureAwait(false); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/MouseAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.WebBrowser.AsyncInteractions; 6 | 7 | namespace Zu.AsyncWebDriver.Interactions.Internal 8 | { 9 | /// 10 | /// Defines an action for mouse interaction with the browser. 11 | /// 12 | public class MouseAction : WebDriverAction 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The with which the action will be performed. 18 | /// An describing an element at which to perform the action. 19 | public MouseAction(IMouse mouse, ILocatable target): base (target) 20 | { 21 | Mouse = mouse; 22 | } 23 | 24 | /// 25 | /// Gets the coordinates at which to perform the mouse action. 26 | /// 27 | protected ICoordinates ActionLocation => ActionTarget?.Coordinates; 28 | /// 29 | /// Gets the mouse with which to perform the action. 30 | /// 31 | protected IMouse Mouse 32 | { 33 | get; 34 | } 35 | 36 | /// 37 | /// Moves the mouse to the location at which to perform the action. 38 | /// 39 | protected async Task MoveToLocation(CancellationToken cancellationToken = new CancellationToken()) 40 | { 41 | // Only call MouseMove if an actual location was provided. If not, 42 | // the action will happen in the last known location of the mouse 43 | // cursor. 44 | if (ActionLocation != null) 45 | await Mouse.MouseMove(ActionLocation, cancellationToken).ConfigureAwait(false); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/MoveMouseAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Zu.AsyncWebDriver.Interactions.Internal; 7 | using Zu.WebBrowser.AsyncInteractions; 8 | 9 | namespace Zu.AsyncWebDriver.Interactions 10 | { 11 | /// 12 | /// Defines an action for moving the mouse to a specified location. 13 | /// 14 | public class MoveMouseAction : MouseAction, IAction 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The with which the action will be performed. 20 | /// An describing an element at which to perform the action. 21 | public MoveMouseAction(IMouse mouse, ILocatable actionTarget): base (mouse, actionTarget) 22 | { 23 | if (actionTarget == null) 24 | throw new ArgumentException("Must provide a location for a move action.", "actionTarget"); 25 | } 26 | 27 | /// 28 | /// Performs this action. 29 | /// 30 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 31 | { 32 | await Mouse.MouseMove(ActionLocation, cancellationToken).ConfigureAwait(false); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/MoveToOffsetAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.AsyncWebDriver.Interactions.Internal; 6 | using Zu.WebBrowser.AsyncInteractions; 7 | 8 | namespace Zu.AsyncWebDriver.Interactions 9 | { 10 | /// 11 | /// Defines an action for moving the mouse to a specified offset from its current location. 12 | /// 13 | public class MoveToOffsetAction : MouseAction, IAction 14 | { 15 | private readonly int offsetX; 16 | private readonly int offsetY; 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The with which the action will be performed. 21 | /// An describing an element at which to perform the action. 22 | /// The horizontal offset from the origin of the target to which to move the mouse. 23 | /// The vertical offset from the origin of the target to which to move the mouse. 24 | public MoveToOffsetAction(IMouse mouse, ILocatable actionTarget, int offsetX, int offsetY): base (mouse, actionTarget) 25 | { 26 | this.offsetX = offsetX; 27 | this.offsetY = offsetY; 28 | } 29 | 30 | /// 31 | /// Performs this action. 32 | /// 33 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 34 | { 35 | await Mouse.MouseMove(ActionLocation, offsetX, offsetY, cancellationToken).ConfigureAwait(false); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/ScreenMoveAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.AsyncWebDriver.Interactions.Internal; 6 | using Zu.WebBrowser.AsyncInteractions; 7 | 8 | namespace Zu.AsyncWebDriver.Interactions 9 | { 10 | /// 11 | /// Presses a touch screen at a given location. 12 | /// 13 | public class ScreenMoveAction : TouchAction, IAction 14 | { 15 | private readonly int x; 16 | private readonly int y; 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The with which the action will be performed. 21 | /// The x coordinate relative to the view port. 22 | /// The y coordinate relative to the view port. 23 | public ScreenMoveAction(ITouchScreen touchScreen, int x, int y): base (touchScreen, null) 24 | { 25 | this.x = x; 26 | this.y = y; 27 | } 28 | 29 | /// 30 | /// Performs the action. 31 | /// 32 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 33 | { 34 | await TouchScreen.Move(x, y, cancellationToken).ConfigureAwait(false); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/ScreenPressAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.AsyncWebDriver.Interactions.Internal; 6 | using Zu.WebBrowser.AsyncInteractions; 7 | 8 | namespace Zu.AsyncWebDriver.Interactions 9 | { 10 | /// 11 | /// Presses a touch screen at a given location. 12 | /// 13 | public class ScreenPressAction : TouchAction, IAction 14 | { 15 | private readonly int x; 16 | private readonly int y; 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The with which the action will be performed. 21 | /// The x coordinate relative to the view port. 22 | /// The y coordinate relative to the view port. 23 | public ScreenPressAction(ITouchScreen touchScreen, int x, int y): base (touchScreen, null) 24 | { 25 | this.x = x; 26 | this.y = y; 27 | } 28 | 29 | /// 30 | /// Performs the action. 31 | /// 32 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 33 | { 34 | await TouchScreen.Down(x, y, cancellationToken).ConfigureAwait(false); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/ScreenReleaseAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.AsyncWebDriver.Interactions.Internal; 6 | using Zu.WebBrowser.AsyncInteractions; 7 | 8 | namespace Zu.AsyncWebDriver.Interactions 9 | { 10 | /// 11 | /// Presses a touch screen at a given location. 12 | /// 13 | public class ScreenReleaseAction : TouchAction, IAction 14 | { 15 | private readonly int x; 16 | private readonly int y; 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The with which the action will be performed. 21 | /// The x coordinate relative to the view port. 22 | /// The y coordinate relative to the view port. 23 | public ScreenReleaseAction(ITouchScreen touchScreen, int x, int y): base (touchScreen, null) 24 | { 25 | this.x = x; 26 | this.y = y; 27 | } 28 | 29 | /// 30 | /// Performs the action. 31 | /// 32 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 33 | { 34 | await TouchScreen.Up(x, y, cancellationToken).ConfigureAwait(false); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/SendKeysAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.AsyncWebDriver.Interactions.Internal; 6 | using Zu.WebBrowser.AsyncInteractions; 7 | 8 | namespace Zu.AsyncWebDriver.Interactions 9 | { 10 | /// 11 | /// Defines an action for sending a sequence of keystrokes to an element. 12 | /// 13 | public class SendKeysAction : KeyboardAction, IAction 14 | { 15 | private readonly string keysToSend; 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The to use in performing the action. 20 | /// The to use in setting focus to the element on which to perform the action. 21 | /// An object providing the element on which to perform the action. 22 | /// The key sequence to send. 23 | public SendKeysAction(IKeyboard keyboard, IMouse mouse, ILocatable actionTarget, string keysToSend): base (keyboard, mouse, actionTarget) 24 | { 25 | this.keysToSend = keysToSend; 26 | } 27 | 28 | /// 29 | /// Performs this action. 30 | /// 31 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 32 | { 33 | await FocusOnElement(cancellationToken).ConfigureAwait(false); 34 | await Keyboard.SendKeys(keysToSend, cancellationToken).ConfigureAwait(false); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/SingleKeyAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using Zu.WebBrowser.AsyncInteractions; 7 | using Zu.WebBrowser.BasicTypes; 8 | 9 | namespace Zu.AsyncWebDriver.Interactions.Internal 10 | { 11 | /// 12 | /// Defines an action for keyboard interaction with the browser using a single modifier key. 13 | /// 14 | public class SingleKeyAction : KeyboardAction 15 | { 16 | private static readonly List ModifierKeys = new List {Keys.Shift, Keys.Control, Keys.Alt}; 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// The to use in performing the action. 22 | /// The to use in setting focus to the element on which to perform the action. 23 | /// An object providing the element on which to perform the action. 24 | /// 25 | /// The modifier key (, , ) to 26 | /// use in the action. 27 | /// 28 | protected SingleKeyAction(IKeyboard keyboard, IMouse mouse, ILocatable actionTarget, string key) : base( 29 | keyboard, mouse, actionTarget) 30 | { 31 | if (!ModifierKeys.Contains(key)) 32 | throw new ArgumentException("key must be a modifier key (Keys.Shift, Keys.Control, or Keys.Alt)", 33 | "key"); 34 | Key = key; 35 | } 36 | 37 | /// 38 | /// Gets the key with which to perform the action. 39 | /// 40 | protected string Key { get; } 41 | } 42 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/SingleTapAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | using System; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Zu.AsyncWebDriver.Interactions.Internal; 7 | using Zu.WebBrowser.AsyncInteractions; 8 | 9 | namespace Zu.AsyncWebDriver.Interactions 10 | { 11 | /// 12 | /// Creates a single tap gesture on a touch screen. 13 | /// 14 | public class SingleTapAction : TouchAction, IAction 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The with which the action will be performed. 20 | /// An describing an element at which to perform the action. 21 | public SingleTapAction(ITouchScreen touchScreen, ILocatable actionTarget): base (touchScreen, actionTarget) 22 | { 23 | if (actionTarget == null) 24 | throw new ArgumentException("Must provide a location for a single tap action.", "actionTarget"); 25 | } 26 | 27 | /// 28 | /// Performs the action. 29 | /// 30 | public async Task Perform(CancellationToken cancellationToken = new CancellationToken()) 31 | { 32 | await TouchScreen.SingleTap(ActionLocation, cancellationToken).ConfigureAwait(false); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/TouchAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using Zu.WebBrowser.AsyncInteractions; 5 | 6 | namespace Zu.AsyncWebDriver.Interactions.Internal 7 | { 8 | /// 9 | /// Defines an action for keyboard interaction with the browser. 10 | /// 11 | public class TouchAction : WebDriverAction 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// The to use in performing the action. 17 | /// An object providing the element on which to perform the action. 18 | protected TouchAction(ITouchScreen touchScreen, ILocatable actionTarget) : base(actionTarget) 19 | { 20 | TouchScreen = touchScreen; 21 | } 22 | 23 | /// 24 | /// Gets the touch screen with which to perform the action. 25 | /// 26 | protected ITouchScreen TouchScreen { get; } 27 | 28 | /// 29 | /// Gets the location at which to perform the action. 30 | /// 31 | protected ICoordinates ActionLocation => ActionTarget?.Coordinates; 32 | } 33 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Interactions/WebDriverAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using Zu.WebBrowser.AsyncInteractions; 5 | 6 | namespace Zu.AsyncWebDriver.Interactions.Internal 7 | { 8 | /// 9 | /// Defines an action for keyboard and mouse interaction with the browser. 10 | /// 11 | public abstract class WebDriverAction 12 | { 13 | /// 14 | /// Initializes a new instance of the class for the given element. 15 | /// 16 | /// An object that provides coordinates for this action. 17 | protected WebDriverAction(ILocatable actionLocation) 18 | { 19 | ActionTarget = actionLocation; 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of the class. 24 | /// 25 | /// This action will take place in the context of the previous action's coordinates. 26 | protected WebDriverAction() 27 | { 28 | } 29 | 30 | /// 31 | /// Gets the target of the action providing coordinates of the action. 32 | /// 33 | protected ILocatable ActionTarget { get; } 34 | } 35 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Internal/IWebElementReference.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace Zu.AsyncWebDriver.Internal 7 | { 8 | /// 9 | /// Defines the interface through which the framework can serialize an element to the wire protocol. 10 | /// 11 | public interface IWebElementReference 12 | { 13 | /// 14 | /// Gets the internal ID of the element. 15 | /// 16 | string ElementReferenceId { get; } 17 | 18 | /// 19 | /// Converts an object into an object that represents an element for the wire protocol. 20 | /// 21 | /// A that represents an element in the wire protocol. 22 | Dictionary ToDictionary(); 23 | } 24 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Internal/IWrapsDriver.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | namespace Zu.AsyncWebDriver.Internal 5 | { 6 | /// 7 | /// Defines the interface through which the user can access the driver used to find an element. 8 | /// 9 | public interface IWrapsDriver 10 | { 11 | /// 12 | /// Gets the used to find this element. 13 | /// 14 | IWebDriver WrappedDriver { get; } 15 | } 16 | } -------------------------------------------------------------------------------- /AsyncWebDriver/Internal/IWrapsElement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | namespace Zu.AsyncWebDriver.Internal 5 | { 6 | /// 7 | /// Defines the interface through which the user can discover if there is an underlying element to be used. 8 | /// 9 | public interface IWrapsElement 10 | { 11 | /// 12 | /// Gets the wrapped by this object. 13 | /// 14 | IWebElement WrappedElement { get; } 15 | } 16 | } -------------------------------------------------------------------------------- /AsyncWebDriver/SyncWrapper/SyncAlert.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | // This file is based on or incorporates material from the project Selenium, licensed under the Apache License, Version 2.0. More info in THIRD-PARTY-NOTICES file. 3 | 4 | using Zu.WebBrowser.AsyncInteractions; 5 | 6 | namespace Zu.AsyncWebDriver.Remote 7 | { 8 | public class SyncAlert 9 | { 10 | private IAlert alert; 11 | 12 | public SyncAlert(IAlert alert) 13 | { 14 | this.alert = alert; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /AsyncWebDriver/SyncWrapper/SyncKeyboard.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | using System; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Zu.WebBrowser.AsyncInteractions; 6 | 7 | namespace Zu.AsyncWebDriver.Remote 8 | { 9 | public class SyncKeyboard 10 | { 11 | private IKeyboard keyboard; 12 | public SyncKeyboard(IKeyboard keyboard) 13 | { 14 | this.keyboard = keyboard; 15 | } 16 | 17 | public void PressKey(string keyToPress) 18 | { 19 | var MRes = new ManualResetEventSlim(true); 20 | MRes.Reset(); 21 | Exception exception = null; 22 | Task.Run(async () => 23 | { 24 | try 25 | { 26 | await keyboard.PressKey(keyToPress).ConfigureAwait(false); 27 | } 28 | catch (Exception ex) 29 | { 30 | exception = ex; 31 | } 32 | 33 | MRes.Set(); 34 | } 35 | 36 | ); 37 | MRes.Wait(); 38 | if (exception != null) 39 | throw exception; 40 | } 41 | 42 | public void SendKeys(string keySequence) 43 | { 44 | var MRes = new ManualResetEventSlim(true); 45 | MRes.Reset(); 46 | Exception exception = null; 47 | Task.Run(async () => 48 | { 49 | try 50 | { 51 | await keyboard.SendKeys(keySequence).ConfigureAwait(false); 52 | } 53 | catch (Exception ex) 54 | { 55 | exception = ex; 56 | } 57 | 58 | MRes.Set(); 59 | } 60 | 61 | ); 62 | MRes.Wait(); 63 | if (exception != null) 64 | throw exception; 65 | } 66 | 67 | public void ReleaseKey(string keyToRelease) 68 | { 69 | var MRes = new ManualResetEventSlim(true); 70 | MRes.Reset(); 71 | Exception exception = null; 72 | Task.Run(async () => 73 | { 74 | try 75 | { 76 | await keyboard.ReleaseKey(keyToRelease).ConfigureAwait(false); 77 | } 78 | catch (Exception ex) 79 | { 80 | exception = ex; 81 | } 82 | 83 | MRes.Set(); 84 | } 85 | 86 | ); 87 | MRes.Wait(); 88 | if (exception != null) 89 | throw exception; 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /AsyncWebDriver/SyncWrapper/SyncLogs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Zu.WebBrowser.BrowserOptions; 4 | 5 | namespace Zu.AsyncWebDriver.Remote 6 | { 7 | public class SyncLogs 8 | { 9 | private ILogs logs; 10 | 11 | public SyncLogs(ILogs logs) 12 | { 13 | this.logs = logs; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /AsyncWebDriver/SyncWrapper/SyncOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Zu.WebBrowser.BrowserOptions; 4 | 5 | namespace Zu.AsyncWebDriver.Remote 6 | { 7 | public class SyncOptions 8 | { 9 | private IOptions options; 10 | 11 | public SyncOptions(IOptions options) 12 | { 13 | this.options = options; 14 | } 15 | 16 | public SyncCookieJar Cookies => new SyncCookieJar(options.Cookies); 17 | public SyncWindow Window => new SyncWindow(options.Window); 18 | public SyncLogs Logs => new SyncLogs(options.Logs); 19 | public SyncTimeouts Timeouts => new SyncTimeouts(options.Timeouts); 20 | 21 | } 22 | } -------------------------------------------------------------------------------- /AsyncWebDriver/SyncWrapper/SyncWindow.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Zu.WebBrowser.BrowserOptions; 4 | 5 | namespace Zu.AsyncWebDriver.Remote 6 | { 7 | public class SyncWindow 8 | { 9 | private IWindow window; 10 | 11 | public SyncWindow(IWindow window) 12 | { 13 | this.window = window; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | AsyncWebDriver in it base was rewritten from selenium dotnet WebDriver hosted on 2 | https://github.com/SeleniumHQ/selenium/tree/master/dotnet/src/webdriver. 3 | 4 | WebBrowserCommunication is based on Communication lib from Node.js Tools for Visual Studio 5 | to which we added connection to Firefox Marionette. 6 | Node.js Tools for Visual Studio Communication part hosted on 7 | https://github.com/Microsoft/nodejstools/tree/master/Nodejs/Product/Nodejs/Debugger/Communication 8 | 9 | For third-party license information see the THIRD-PARTY-NOTICES file which accompanies this NOTICE file. 10 | -------------------------------------------------------------------------------- /THIRD-PARTY-NOTICES: -------------------------------------------------------------------------------- 1 | AsyncWebDriver uses third-party libraries or other resources that may be 2 | distributed under licenses different than the AsyncWebDriver software. 3 | 4 | In the event that we accidentally failed to list a required notice, please 5 | bring it to our attention. Post an issue or email us: 6 | 7 | tocsharp@gmail.com 8 | 9 | AsyncWebDriver that this document references does not necessarily use 10 | all the open source software packages referred to below and may also 11 | only use portions of a given package. More info in "NOTICE" file. 12 | 13 | The attached notices are provided for information only. 14 | 15 | License notice for Newtonsoft.Json 16 | ------------------------------- 17 | 18 | https://raw.githubusercontent.com/JamesNK/Newtonsoft.Json/master/LICENSE.md 19 | 20 | The MIT License (MIT) 21 | 22 | Copyright (c) 2007 James Newton-King 23 | 24 | Permission is hereby granted, free of charge, to any person obtaining a copy of 25 | this software and associated documentation files (the "Software"), to deal in 26 | the Software without restriction, including without limitation the rights to 27 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 28 | the Software, and to permit persons to whom the Software is furnished to do so, 29 | subject to the following conditions: 30 | 31 | The above copyright notice and this permission notice shall be included in all 32 | copies or substantial portions of the Software. 33 | 34 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 37 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 38 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 39 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 40 | 41 | 42 | License notice for Selenium 43 | ------------------------------- 44 | 45 | https://github.com/SeleniumHQ/selenium/blob/master/LICENSE 46 | 47 | Licensed under the Apache License, Version 2.0 (the “License”); 48 | you may not use this file except in compliance with the License. 49 | You may obtain a copy of the License at 50 | http://www.apache.org/licenses/LICENSE-2.0 51 | 52 | 53 | License notice for Node.js Tools for Visual Studio 54 | ------------------------------- 55 | 56 | https://github.com/Microsoft/nodejstools/blob/master/LICENSE 57 | 58 | Licensed under the Apache License, Version 2.0 (the “License”); 59 | you may not use this file except in compliance with the License. 60 | You may obtain a copy of the License at 61 | http://www.apache.org/licenses/LICENSE-2.0 62 | -------------------------------------------------------------------------------- /WebBrowserCommunication/AsyncProducerConsumerCollection.cs: -------------------------------------------------------------------------------- 1 | //*********************************************************// 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // 4 | // Apache 2.0 License 5 | // 6 | // You may obtain a copy of the License at 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. 14 | // 15 | //*********************************************************// 16 | 17 | using System.Collections.Generic; 18 | using System.Threading.Tasks; 19 | 20 | namespace Zu.WebBrowser.Communication { 21 | public class AsyncProducerConsumerCollection { 22 | private readonly Queue _collection = new Queue(); 23 | private readonly Queue> _waiting = new Queue>(); 24 | 25 | public void Add(T item) { 26 | TaskCompletionSource tcs = null; 27 | lock (_collection) { 28 | if (_waiting.Count > 0) { 29 | tcs = _waiting.Dequeue(); 30 | } else { 31 | _collection.Enqueue(item); 32 | } 33 | } 34 | if (tcs != null) { 35 | tcs.TrySetResult(item); 36 | } 37 | } 38 | 39 | public Task TakeAsync() { 40 | lock (_collection) { 41 | if (_collection.Count > 0) { 42 | return Task.FromResult(_collection.Dequeue()); 43 | } 44 | var tcs = new TaskCompletionSource(); 45 | _waiting.Enqueue(tcs); 46 | return tcs.Task; 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /WebBrowserCommunication/DebuggerCommandException.cs: -------------------------------------------------------------------------------- 1 | //*********************************************************// 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // 4 | // Apache 2.0 License 5 | // 6 | // You may obtain a copy of the License at 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. 14 | // 15 | //*********************************************************// 16 | 17 | using System; 18 | using System.Runtime.Serialization; 19 | 20 | namespace Zu.WebBrowser.Commands { 21 | [Serializable] 22 | public class DebuggerCommandException : Exception { 23 | public DebuggerCommandException() { } 24 | public DebuggerCommandException(string message) : base(message) { } 25 | public DebuggerCommandException(string message, Exception innerException) : base(message, innerException) { } 26 | protected DebuggerCommandException(SerializationInfo info, StreamingContext context) : base(info, context) { } 27 | } 28 | } -------------------------------------------------------------------------------- /WebBrowserCommunication/IDebuggerClient.cs: -------------------------------------------------------------------------------- 1 | //*********************************************************// 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // 4 | // Apache 2.0 License 5 | // 6 | // You may obtain a copy of the License at 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. 14 | // 15 | //*********************************************************// 16 | 17 | using System; 18 | using System.Threading; 19 | using System.Threading.Tasks; 20 | using Zu.WebBrowser.Commands; 21 | 22 | namespace Zu.WebBrowser.Communication { 23 | public interface IDebuggerClient { 24 | /// 25 | /// Send a command to debugger. 26 | /// 27 | /// Command. 28 | /// Cancellation token. 29 | Task SendRequestAsync(DebuggerCommand command, CancellationToken cancellationToken = new CancellationToken()); 30 | 31 | } 32 | } -------------------------------------------------------------------------------- /WebBrowserCommunication/IDebuggerConnection.cs: -------------------------------------------------------------------------------- 1 | //*********************************************************// 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // 4 | // Apache 2.0 License 5 | // 6 | // You may obtain a copy of the License at 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. 14 | // 15 | //*********************************************************// 16 | 17 | using System; 18 | 19 | namespace Zu.WebBrowser.Communication { 20 | public interface IDebuggerConnection : IDisposable { 21 | /// 22 | /// Gets a value indicating whether connection established. 23 | /// 24 | bool Connected { get; } 25 | 26 | 27 | /// 28 | /// Connect to specified debugger endpoint. 29 | /// 30 | /// URI identifying the endpoint to connect to. 31 | void Connect(Uri uri); 32 | 33 | /// 34 | /// Close connection. 35 | /// 36 | void Close(); 37 | 38 | /// 39 | /// Send a message. 40 | /// 41 | /// Message. 42 | void SendMessage(string message); 43 | 44 | /// 45 | /// Fired when received inbound message. 46 | /// 47 | event EventHandler OutputMessage; 48 | 49 | /// 50 | /// Fired when connection was closed. 51 | /// 52 | event EventHandler ConnectionClosed; 53 | } 54 | } -------------------------------------------------------------------------------- /WebBrowserCommunication/INetworkClient.cs: -------------------------------------------------------------------------------- 1 | //*********************************************************// 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // 4 | // Apache 2.0 License 5 | // 6 | // You may obtain a copy of the License at 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. 14 | // 15 | //*********************************************************// 16 | 17 | using System; 18 | using System.IO; 19 | 20 | namespace Zu.WebBrowser.Communication { 21 | public interface INetworkClient : IDisposable { 22 | /// 23 | /// Gets a value indicating whether client is connected to a remote host. 24 | /// 25 | bool Connected { get; } 26 | 27 | /// 28 | /// Returns the used to send and receive data. 29 | /// 30 | /// The underlying 31 | Stream GetStream(); 32 | } 33 | } -------------------------------------------------------------------------------- /WebBrowserCommunication/INetworkClientFactory.cs: -------------------------------------------------------------------------------- 1 | //*********************************************************// 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // 4 | // Apache 2.0 License 5 | // 6 | // You may obtain a copy of the License at 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. 14 | // 15 | //*********************************************************// 16 | 17 | using System; 18 | 19 | namespace Zu.WebBrowser.Communication { 20 | public interface INetworkClientFactory { 21 | INetworkClient CreateNetworkClient(Uri uri); 22 | } 23 | } -------------------------------------------------------------------------------- /WebBrowserCommunication/LiveLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Zu.WebBrowser.Logging 4 | { 5 | public class LiveLogger 6 | { 7 | public static event EventHandler OnMessage; 8 | 9 | public static void WriteLine(string v, object obj = null, Exception ex = null) 10 | { 11 | OnMessage?.Invoke(null, v); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /WebBrowserCommunication/MessageEventArgs.cs: -------------------------------------------------------------------------------- 1 | //*********************************************************// 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // 4 | // Apache 2.0 License 5 | // 6 | // You may obtain a copy of the License at 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. 14 | // 15 | //*********************************************************// 16 | 17 | using System; 18 | 19 | namespace Zu.WebBrowser.Communication { 20 | public class MessageEventArgs : EventArgs { 21 | public MessageEventArgs(string message) { 22 | Message = message; 23 | } 24 | 25 | public string Message { get; private set; } 26 | } 27 | } -------------------------------------------------------------------------------- /WebBrowserCommunication/NetworkClientFactory.cs: -------------------------------------------------------------------------------- 1 | //*********************************************************// 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // 4 | // Apache 2.0 License 5 | // 6 | // You may obtain a copy of the License at 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. 14 | // 15 | //*********************************************************// 16 | 17 | using System; 18 | 19 | namespace Zu.WebBrowser.Communication { 20 | public class NetworkClientFactory : INetworkClientFactory { 21 | public INetworkClient CreateNetworkClient(Uri uri) { 22 | if (uri == null) { 23 | throw new ArgumentNullException(nameof(uri)); 24 | } 25 | 26 | if (uri.IsAbsoluteUri) { 27 | switch (uri.Scheme) { 28 | case "tcp": 29 | if (uri.Port < 0) { 30 | throw new ArgumentException("tcp:// URI must include port number", nameof(uri)); 31 | } 32 | return new TcpNetworkClient(uri.Host, uri.Port); 33 | case "ws": 34 | case "wss": 35 | return new WebSocketNetworkClient(uri); 36 | } 37 | } 38 | 39 | throw new ArgumentException("tcp://, ws:// or wss:// URI required", nameof(uri)); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /WebBrowserCommunication/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Общие сведения об этой сборке предоставляются следующим набором 6 | // набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, 7 | // связанные со сборкой. 8 | [assembly: AssemblyTitle("WebBrowserCommunication")] 9 | [assembly: AssemblyDescription("Communication with WebBrowsers lib")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Oleg Zudov")] 12 | [assembly: AssemblyProduct("WebBrowserCommunication")] 13 | [assembly: AssemblyCopyright("Copyright © Oleg Zudov 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми 18 | // для компонентов COM. Если необходимо обратиться к типу в этой сборке через 19 | // COM, задайте атрибуту ComVisible значение TRUE для этого типа. 20 | [assembly: ComVisible(false)] 21 | 22 | // Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM 23 | [assembly: Guid("bd66d956-659c-4974-b86d-1ae8f75e7f12")] 24 | 25 | // Сведения о версии сборки состоят из следующих четырех значений: 26 | // 27 | // Основной номер версии 28 | // Дополнительный номер версии 29 | // Номер сборки 30 | // Редакция 31 | // 32 | // Можно задать все значения или принять номер сборки и номер редакции по умолчанию. 33 | // используя "*", как показано ниже: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.2.0")] 36 | [assembly: AssemblyFileVersion("1.0.2.0")] 37 | -------------------------------------------------------------------------------- /WebBrowserCommunication/TcpNetworkClient.cs: -------------------------------------------------------------------------------- 1 | //*********************************************************// 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // 4 | // Apache 2.0 License 5 | // 6 | // You may obtain a copy of the License at 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. 14 | // 15 | //*********************************************************// 16 | 17 | using System.IO; 18 | using System.Net.Sockets; 19 | 20 | namespace Zu.WebBrowser.Communication { 21 | public class TcpNetworkClient : INetworkClient { 22 | private readonly TcpClient _tcpClient; 23 | 24 | public TcpNetworkClient(string hostName, int portNumber) { 25 | _tcpClient = new TcpClient(hostName, portNumber); 26 | } 27 | 28 | public bool Connected => _tcpClient.Connected; 29 | 30 | public void Dispose() { 31 | _tcpClient.Close(); 32 | } 33 | 34 | public Stream GetStream() => _tcpClient.GetStream(); 35 | } 36 | } -------------------------------------------------------------------------------- /WebBrowserCommunication/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /ZuRequestListener/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Общие сведения об этой сборке предоставляются следующим набором 6 | // набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, 7 | // связанные со сборкой. 8 | [assembly: AssemblyTitle("ZuRequestListener")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ZuRequestListener")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми 18 | // для компонентов COM. Если необходимо обратиться к типу в этой сборке через 19 | // COM, задайте атрибуту ComVisible значение TRUE для этого типа. 20 | [assembly: ComVisible(false)] 21 | 22 | // Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM 23 | [assembly: Guid("bc277712-931f-4201-9cd2-16cd92565f93")] 24 | 25 | // Сведения о версии сборки состоят из следующих четырех значений: 26 | // 27 | // Основной номер версии 28 | // Дополнительный номер версии 29 | // Номер сборки 30 | // Редакция 31 | // 32 | // Можно задать все значения или принять номер сборки и номер редакции по умолчанию. 33 | // используя "*", как показано ниже: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.1.0")] 36 | [assembly: AssemblyFileVersion("1.0.1.0")] 37 | -------------------------------------------------------------------------------- /ZuRequestListener/ZuRequestInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Oleg Zudov. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | namespace Zu.Browser 4 | { 5 | public class ZuRequestInfo 6 | { 7 | public string Body { get; set; } 8 | public string Url { get; set; } 9 | public string Code { get; set; } 10 | 11 | public override string ToString() 12 | { 13 | return Url; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /ZuRequestListener/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | --------------------------------------------------------------------------------