internal static Alert SwitchToAlert(RemoteSession session, int timeout) { string text; try { text = (string)session.Send(RequestMethod.GET, "/alert_text"); } catch (Errors.NoAlertPresentError) { if (timeout == 0) { throw; } DateTime endTime = session.GetEndTime(timeout); while (true) { SysWaiter.Wait(); try { text = (string)session.SendAgain(); break; } catch (Errors.NoAlertPresentError) { if (DateTime.UtcNow > endTime) { throw; } } } } return(new Alert(session, text)); }
internal Cookies(RemoteSession session, List rawCookies) : base(rawCookies.Count) { _count = _items.Length; for (int i = 0; i < _count; i++) { _items[i] = new Cookie(session, (Dictionary)rawCookies[i]); } }
public void TestWebSocketChangeTrackerFallback() { if (!Boolean.Parse((string)GetProperty("replicationTestsEnabled"))) { Assert.Inconclusive("Replication tests disabled."); return; } var signal = new CountdownEvent(1); var client = new ChangeTrackerTestClient(signal, null); using (var remoteDb = _sg.CreateDatabase("web_socket_scratch")) { var remoteSession = new RemoteSession(new RemoteSessionContructorOptions { BaseUrl = remoteDb.RemoteUri }); remoteSession.SetupHttpClientFactory(null, database, "live"); remoteSession.Setup(new ReplicationOptions()); var tracker = new BadWebSocketChangeTracker(new ChangeTrackerOptions { DatabaseUri = remoteDb.RemoteUri, IncludeConflicts = false, Client = client, RetryStrategy = new ExponentialBackoffStrategy(2), RemoteSession = remoteSession }); tracker.Start(); Assert.IsTrue(signal.Wait(TimeSpan.FromSeconds(20))); Assert.IsFalse(tracker.CanConnect); } }
private WebElement FindAnyElement(By byAny, int timeout) { RemoteSession session = this.session; string relativeUri = this.uri + "/element"; Dictionary element; DateTime endTime = session.GetEndTime(timeout); while (true) { foreach (By by in (By[])byAny.Value) { if (by == null) { break; } try { string method = By.FormatStrategy(by.Strategy); string value = by.Value.ToString(); element = (Dictionary)session.Send(RequestMethod.POST, relativeUri, "using", method, "value", value); return(new WebElement(session, element)); } catch (Errors.NoSuchElementError) { } } if (DateTime.UtcNow > endTime) { throw new Errors.NoSuchElementError(byAny); } SysWaiter.Wait(); } }
private void StartConnectSession(RemoteSession session) { Thread connectSession = new Thread(new ThreadStart(() => { Chrome chrome = new Chrome(); chrome.Connect(session.webSocketDebuggerUrl); lock (locker) { int browserid = CountAdded + 1; chrome.SetBrowserId(browserid); string name = this.CoinsIndexed[this.CountAdded]; this.Browsers.Add(name, chrome); this.CountAdded++; this.OnSocketConnected(this, new SocketConnectedEventArgs(this.CountAdded, this.Coins.Count * 2)); if (this.CountAdded == this.Coins.Count * 2) { this.OnComplete(this, new AttachBrowsersCompleteEventArgs(this.Browsers)); } } })); connectSession.Start(); }
internal Actions(RemoteSession session) { _session = session; _mouse = session.mouse; _keyboard = session.keyboard; _actions = new List <Action>(); }
private WebElements FindAnyElements(By byAny, int minimum, int timeout) { RemoteSession session = this.session; string uri = this.uri + "/elements"; WebElements webelements = new WebElements(); DateTime endTime = session.GetEndTime(timeout); while (true) { foreach (By by in (By[])byAny.Value) { if (by == null) { break; } var method = By.FormatStrategy(by.Strategy); var value = (string)by.Value; List elements = (List)session.Send(RequestMethod.POST, uri, "using", method, "value", value); webelements.Add(session, elements); } if (webelements.Count >= minimum) { return(webelements); } if (DateTime.UtcNow > endTime) { throw new Errors.NoSuchElementError(byAny); } SysWaiter.Wait(); } }
internal Window(RemoteSession session, WindowContext windows, string handle) { _session = session; _windows = windows; _handle = handle; if (handle != null) _hash = handle.GetHashCode(); }
/// <summary> /// Returns a web element matching the given method and value /// </summary> private void WaitAnyElementNotPresent(By byAny, int timeout) { RemoteSession session = this.session; string uri = this.uri + "/element"; DateTime endTime = session.GetEndTime(timeout); foreach (By by in (By[])byAny.Value) { if (by == null) { break; } try { string method = By.FormatStrategy(by.Strategy); string value = by.Value.ToString(); session.Send(RequestMethod.POST, uri, "using", method, "value", value); while (true) { if (DateTime.UtcNow > endTime) { throw new Errors.ElementPresentError(byAny); } SysWaiter.Wait(); session.SendAgain(); } } catch (Errors.NoSuchElementError) { } } }
/// <summary> /// Returns a web element matching the given method and value or null if no element found /// </summary> private WebElement FindFirstElement(Strategy strategy, string value, int timeout) { RemoteSession session = this.session; string relativeUri = this.uri + "/element"; Dictionary element; try { string method = By.FormatStrategy(strategy); element = (Dictionary)session.Send(RequestMethod.POST, relativeUri, "using", method, "value", value); } catch (Errors.NoSuchElementError) { if (timeout == 0) { throw; } var endTime = session.GetEndTime(timeout); while (true) { SysWaiter.Wait(); try { element = (Dictionary)session.SendAgain(); break; } catch (Errors.NoSuchElementError) { if (DateTime.UtcNow > endTime) { throw; } } } } return(new WebElement(session, element)); }
/// <summary> /// Adds a new cookie. /// </summary> /// <param name="session"></param> /// <param name="name"></param> /// <param name="value"></param> /// <param name="path"></param> /// <param name="domain"></param> /// <param name="expiry"></param> /// <param name="secure"></param> /// <param name="httpOnly"></param> internal static void AddOne(RemoteSession session, string name, string value, string path, string domain, string expiry, bool secure, bool httpOnly) { var dict = new Dictionary(); dict.Add("name", name); dict.Add("value", value); if (path != null) { dict.Add("path", path); } if (domain != null) { dict.Add("domain", domain); } if (expiry != null) { var dt = (long)(DateTime.Parse(expiry) - Cookie.BASE_TIME).TotalSeconds; dict.Add("expiry", dt); } if (secure == true) { dict.Add("secure", true); } if (httpOnly == true) { dict.Add("httpOnly", true); } session.Send(RequestMethod.POST, "/cookie", "cookie", dict); }
public void TestChangeTrackerGiveUp() { var factory = new MockHttpClientFactory(); var httpHandler = (MockHttpRequestHandler)factory.HttpHandler; httpHandler.AddResponderThrowExceptionAllRequests(); var changeTrackerFinishedSignal = new CountdownEvent(1); var client = new ChangeTrackerTestClient(changeTrackerFinishedSignal, null); client.HttpClientFactory = factory; var testUrl = GetReplicationURL(); var scheduler = new SingleTaskThreadpoolScheduler(); var remoteSession = new RemoteSession(new RemoteSessionContructorOptions { BaseUrl = testUrl, WorkExecutor = new TaskFactory(scheduler) }); remoteSession.SetupHttpClientFactory(client.HttpClientFactory, database, "giveup"); remoteSession.Setup(new ReplicationOptions()); var changeTracker = ChangeTrackerFactory.Create(new ChangeTrackerOptions { DatabaseUri = testUrl, Mode = ChangeTrackerMode.OneShot, IncludeConflicts = true, Client = client, RetryStrategy = new ExponentialBackoffStrategy(2), WorkExecutor = new TaskFactory(scheduler), RemoteSession = remoteSession }); changeTracker.Start(); Assert.IsTrue(changeTrackerFinishedSignal.Wait(TimeSpan.FromSeconds(30))); }
internal TableElement(RemoteSession session, WebElement element) { _session = session; _element = element; var tag = _element.TagName.ToLowerInvariant(); if ("table" != tag && "tbody" != tag) throw new Errors.UnexpectedTagNameError("table,tbody", tag); }
public void TestChangeTrackerWithDocsIds() { var testURL = GetReplicationURL(); var remoteSession = new RemoteSession(new RemoteSessionContructorOptions { BaseUrl = testURL }); remoteSession.SetupHttpClientFactory(null, database, "docids"); remoteSession.Setup(new ReplicationOptions()); var changeTracker = ChangeTrackerFactory.Create(new ChangeTrackerOptions { DatabaseUri = testURL, Mode = ChangeTrackerMode.LongPoll, IncludeConflicts = false, Client = new ChangeTrackerTestClient(null, null), RetryStrategy = new ExponentialBackoffStrategy(2), RemoteSession = remoteSession }); var docIds = new List <string>(); docIds.Add("doc1"); docIds.Add("doc2"); changeTracker.DocIDs = docIds; var parameters = changeTracker.GetChangesFeedParams(); Assert.AreEqual("_doc_ids", parameters["filter"]); AssertEnumerablesAreEqual(docIds, (IEnumerable)parameters["doc_ids"]); }
/// <summary> /// Initializes a new instance of the <see cref="ResourceManager"/> class. /// </summary> /// <param name="rmtSession">Remote session</param> public ResourceManager(RemoteSession rmtSession) { this.remoteSession = rmtSession; this.highPriorityDownloadManager = new ResourceDownloadManager(this.remoteSession); this.lowPriorityDownloadManager = new ResourceDownloadManager(this.remoteSession); this.platformService = SimpleIoc.Default.GetInstance <IPlatformService>(); }
internal WebElements(RemoteSession session, List rawElements) : base(rawElements.Count) { _count = _items.Length; for (int i = 0; i < _count; i++) { _items[i] = new WebElement(session, (Dictionary)rawElements[i]); } }
/// <summary> /// Initializes a new instance of the <see cref="ServerOperationManager"/> class. /// </summary> /// <param name="server"> /// The server. /// </param> /// <param name="languageKey"> /// The language key. /// </param> /// <param name="username"> /// The username. /// </param> /// <param name="password"> /// The password. /// </param> /// <param name="passwordNew"> /// The password new. /// </param> /// <param name="rasInstanceName"> /// Name of the ras instance. /// </param> /// <param name="remoteSession"> /// The remote session. /// </param> /// <param name="theDelegate"> /// The delegate. /// </param> /// <param name="userChoiceOffline"> /// if set to <c>true</c> [user choice offline]. /// </param> public ServerOperationManager( RemoteServer server, string languageKey, string username, string password, string passwordNew, string rasInstanceName, RemoteSession remoteSession, IOperationManagerDelegate theDelegate, bool userChoiceOffline) { this.crmServer = server; this.languageKey = languageKey; this.loginName = username; this.Password = password; this.Delegate = theDelegate; this.remoteSession = remoteSession; this.RasInstanceName = rasInstanceName; this.UserChoiceOffline = userChoiceOffline; this.newPassword = passwordNew; this.serverOperations = new List <Operation>(); this.startingUp = true; this.ConnectionWatchDog = SimpleIoc.Default.GetInstance <IConnectionWatchdog>()?.ConnectionWatchDogForServerURL(server.OriginalServerUrl); // Set the credentials switch (this.crmServer.AuthenticationType) { case ServerAuthenticationType.Revolution: break; case ServerAuthenticationType.SSO: this.loginName = null; this.Password = null; break; case ServerAuthenticationType.SSOCredentialNoCache: case ServerAuthenticationType.SSOCredentialSessionCache: this.ServerRequestCredentials = new NetworkCredential(this.loginName, this.Password); this.loginName = null; this.Password = null; break; case ServerAuthenticationType.UsernamePassword: break; case ServerAuthenticationType.UsernamePasswordCredentials: this.ServerRequestCredentials = new NetworkCredential { UserName = this.crmServer.NetworkUsername, Password = this.crmServer.NetworkPassword }; break; } Messenger.Default.Register <ConnectionWatchDogMessage>(this, ConnectionWatchDogMessageKey.DidEstablishServerConnectivity, this.ConnectionWatchDogDidEstablishServerConnectivity); Messenger.Default.Register <ConnectionWatchDogMessage>(this, ConnectionWatchDogMessageKey.DidLooseServerConnectivity, this.ConnectionWatchDogDidLooseServerConnectivity); Messenger.Default.Register <ConnectionWatchDogMessage>(this, ConnectionWatchDogMessageKey.DidChangeConnectivityQuality, this.ConnectionWatchDogDidChangeConnectivityQuality); Task.Factory.StartNew(this.StopStartingUp); }
internal WebElement(RemoteSession session, Dictionary dict) { _session = session; if (!WebElement.TryParse(dict, out this.Id)) { throw new SeleniumException("Failed to extact the WebElement from the dictionary. Missing key."); } }
public WindowContext(RemoteSession session) : base() { _session = session; _currentWindow = new Window(session, this, null); _previousWindow = _currentWindow; _cachedWindows = new List(10); _cachedWindows.Add(_currentWindow); }
internal void Add(RemoteSession session, List rawElements) { int count = rawElements.Count; int size = _count + count; if (size > _items.Length) IncreaseSize(size); for (int i = 0; i < count; i++) { _items[_count++] = new WebElement(session, (Dictionary)rawElements[i]); } }
internal Cookies(RemoteSession session, List rawCookies) : base(rawCookies.Count) { _count = _items.Length; for (int i = 0; i < _count; i++) { _items[i] = new Cookie(session, (Dictionary)rawCookies[i]); } }
/// <summary> /// Get a cookie matching a name from the current page. /// </summary> internal static Cookie FindByName(RemoteSession session, string namePattern) { List cookies = Cookies.GetAll(session); Regex re = new Regex(namePattern, RegexOptions.IgnoreCase); foreach (Dictionary cookie in cookies) { if (re.IsMatch((string)cookie["name"])) return new Cookie(session, cookie); } throw new Errors.NoSuchCookieError("Cookie not found. Pattern: " + namePattern); }
internal WebElements(RemoteSession session, List rawElements) : base(rawElements.Count) { _count = _items.Length; for (int i = 0; i < _count; i++) { _items[i] = new WebElement(session, (Dictionary)rawElements[i]); } }
/// <summary> /// Get a cookie matching a name from the current page. /// </summary> internal static Cookie GetOneByName(RemoteSession session, string namePattern) { List cookies = Cookies.GetAll(session); Regex re = new Regex(namePattern, RegexOptions.IgnoreCase); for (int i = 0, cnt = cookies.Count; i < cnt; i++) { Dictionary cookie = (Dictionary)cookies[i]; if (re.IsMatch((string)cookie["name"])) return new Cookie(session, cookie); } throw new Errors.NoSuchCookieError("Cookie not found. Pattern: " + namePattern); }
internal Window(RemoteSession session, WindowContext windows, string handle) { _session = session; _windows = windows; _handle = handle; if (handle != null) { _hash = handle.GetHashCode(); } }
/// <summary> /// Loads a web page in the current browser session. Same as Open method. /// </summary> /// <param name="url">URL</param> /// <param name="timeout">Optional timeout in milliseconds. Infinite=-1</param> /// <param name="raise">Optional - Raise an exception after the timeout when true</param> /// <returns>Return true if the url was openned within the timeout, false otherwise</returns> public bool Get(string url, int timeout = -1, bool raise = true) { if (_session == null) { this.Start(); } RemoteSession session = _session; if (string.IsNullOrEmpty(url)) { throw new Errors.ArgumentError("Argument 'url' cannot be null."); } if (timeout > 0) { session.timeouts.PageLoad = timeout; session.Send(RequestMethod.POST, "/timeouts", "type", "page load", "ms", timeout); } int idx = url.IndexOf("/"); if (idx == 0) { //relative url if (_baseUrl == null) { throw new Errors.ArgumentError("Base URL not defined. Define a base URL or use a full URL."); } url = string.Concat(_baseUrl, url); } else { //absolute url idx = url.IndexOf('/', idx + 3); if (idx != -1) { _baseUrl = url.Substring(0, idx - 1); } else { _baseUrl = url; } } try { session.Send(RequestMethod.POST, "/url", "url", url); return(true); } catch { if (raise) { throw; } return(false); } }
/// <exception cref="System.Exception"></exception> public BulkDownloader(BulkDownloaderOptions options) { options.Validate(); _bulkGetUri = new Uri(AppendRelativeURLString(options.DatabaseUri, "/_bulk_get?revs=true&attachments=true")); _db = options.Database; _requestHeaders = options.RequestHeaders; _tokenSource = options.TokenSource ?? new CancellationTokenSource(); _body = CreatePostBody(options.Revisions, _db); _session = options.Session; }
private void AttachContentsAvailable(RemoteSession remoteSession) { remoteSession.ContentsAvailable += () => { if (!ReferenceEquals(remoteSession, RemoteSession)) { return; } RemoteContentsAvailable(); }; }
/// <summary>Get the default SSH session</summary> /// <returns>a remote session</returns> /// <exception cref="NGit.Errors.TransportException">in case of error with opening SSH session /// </exception> protected internal virtual RemoteSession GetSession() { if (sock != null) { return(sock); } int tms = GetTimeout() > 0 ? GetTimeout() * 1000 : 0; sock = sch.GetSession(uri, GetCredentialsProvider(), local.FileSystem, tms); return(sock); }
internal TableElement(RemoteSession session, WebElement element) { _session = session; _element = element; var tag = _element.TagName.ToLowerInvariant(); if ("table" != tag && "tbody" != tag) { throw new Errors.UnexpectedTagNameError("table,tbody", tag); } }
private void ChangeTrackerTestWithMode(ChangeTrackerMode mode) { var changeTrackerFinishedSignal = new CountdownEvent(1); var changeReceivedSignal = new CountdownEvent(1); var client = new ChangeTrackerTestClient(changeTrackerFinishedSignal, changeReceivedSignal); client.ReceivedChangeDelegate = (IDictionary <string, object> change) => { Assert.IsTrue(change.ContainsKey("seq")); Assert.AreEqual("1", change["seq"]); }; var handler = client.HttpRequestHandler; handler.SetResponder("_changes", (request) => { var json = "{\"results\":[\n" + "{\"seq\":\"1\",\"id\":\"doc1-138\",\"changes\":[{\"rev\":\"1-82d\"}]}],\n" + "\"last_seq\":\"*:50\"}"; return(MockHttpRequestHandler.GenerateHttpResponseMessage(System.Net.HttpStatusCode.OK, null, json)); }); var testUrl = GetReplicationURL(); var scheduler = new SingleTaskThreadpoolScheduler(); var remoteSession = new RemoteSession(new RemoteSessionContructorOptions { WorkExecutor = new TaskFactory(scheduler), BaseUrl = testUrl }); remoteSession.SetupHttpClientFactory(client.HttpClientFactory, database, "testwithmode"); remoteSession.Setup(new ReplicationOptions()); var changeTracker = ChangeTrackerFactory.Create(new ChangeTrackerOptions { DatabaseUri = testUrl, Mode = mode, IncludeConflicts = false, Client = client, RetryStrategy = new ExponentialBackoffStrategy(2), WorkExecutor = new TaskFactory(scheduler), RemoteSession = remoteSession }); changeTracker.ActiveOnly = true; changeTracker.Start(); var success = changeReceivedSignal.Wait(TimeSpan.FromSeconds(30)); Assert.IsTrue(success); changeTracker.Stop(); success = changeTrackerFinishedSignal.Wait(TimeSpan.FromSeconds(30)); Assert.IsTrue(success); }
public int Process(RemoteSession session) { XDocument response = session.UploadFile( "/do/Upload/", this.filePath, new FileStream(this.filePath, FileMode.Open, FileAccess.Read), "file", Util.getMimeByExtension(Path.GetExtension(this.filePath)), new System.Collections.Specialized.NameValueCollection() ); return int.Parse(response.Root.GetTextValue("uploadedId")); }
internal Cookie(RemoteSession session, Dictionary dict) { _session = session; try { _name = (string)dict["name"]; _value = (string)dict["value"]; _path = (string)dict.Get("path", null); _domain = (string)dict.Get("domain", null); _expiry = (int?)dict.Get("expiry", null); _secure = (bool)dict.Get("secure", false); } catch (Errors.KeyNotFoundError ex) { throw new DeserializeException(typeof(Cookie), ex); } }
public int Process(RemoteSession session) { XDocument response = session.PostRequest( "/do/Reply/", new NameValueCollection { { "parent", this.parentPostId.ToString() }, { "title", this.title }, { "layerId", this.layerId.ToString() }, { "Body", this.bodyUbb }, } ); return int.Parse(response.Root.Element("post").GetTextValue("id")); }
/// <summary> /// Starts a new Selenium testing session /// </summary> /// <param name="browser">Name of the browser : firefox, ie, chrome, phantomjs</param> /// <param name="baseUrl">The base URL</param> /// <example> /// <code lang="vbs"> /// Dim driver As New WebDriver() /// driver.Start "firefox", "http://www.google.com" /// driver.Get "/" /// </code> /// </example> public void Start(string browser = null, string baseUrl = null) { try { browser = ExpendBrowserName(browser); switch (browser) { case "firefox": _service = FirefoxDriver.StartService(this); break; case "chrome": _service = ChromeDriver.StartService(this); break; case "phantomjs": _service = PhantomJSDriver.StartService(this); break; case "internet explorer": _service = IEDriver.StartService(this); break; case "MicrosoftEdge": _service = EdgeDriver.StartService(this); break; case "opera": _service = OperaDriver.StartService(this); break; default: throw new Errors.ArgumentError("Invalid browser name: {0}", browser); } this.Capabilities.BrowserName = browser; RegisterRunningObject(); _session = new RemoteSession(_service.Uri, true, this.timeouts); _session.Start(this.Capabilities); if (!string.IsNullOrEmpty(baseUrl)) { this.BaseUrl = baseUrl; } } catch (SeleniumException) { throw; } catch (Exception ex) { throw new SeleniumException(ex); } }
public override void Close() { if (sock != null) { try { sch.ReleaseSession(sock); } finally { sock = null; } } }
internal void Add(RemoteSession session, List rawElements) { int count = rawElements.Count; int size = _count + count; if (size > _items.Length) { IncreaseSize(size); } for (int i = 0; i < count; i++) { _items[_count++] = new WebElement(session, (Dictionary)rawElements[i]); } }
/// <summary> /// Get a cookie matching a name from the current page. /// </summary> internal static Cookie FindByName(RemoteSession session, string namePattern) { List cookies = Cookies.GetAll(session); Regex re = new Regex(namePattern, RegexOptions.IgnoreCase); foreach (Dictionary cookie in cookies) { if (re.IsMatch((string)cookie["name"])) { return(new Cookie(session, cookie)); } } throw new Errors.NoSuchCookieError("Cookie not found. Pattern: " + namePattern); }
internal Cookie(RemoteSession session, Dictionary dict) { _session = session; try { _name = dict.GetValue("name", string.Empty); _value = dict.GetValue("value", string.Empty); _path = dict.GetValue("path", string.Empty); _domain = dict.GetValue("domain", string.Empty); _secure = Convert.ToBoolean(dict.Get("secure", false)); _expiry = Convert.ToDouble(dict.Get("expiry", 0)); } catch (Errors.KeyNotFoundError ex) { throw new DeserializeException(typeof(Cookie), ex); } catch (Exception ex) { throw new SeleniumException(ex); } }
/// <summary> /// Starts remotely a new Selenium testing session /// </summary> /// <param name="executorUri">Remote executor address (ex : "http://localhost:4444/wd/hub")</param> /// <param name="browser">Name of the browser : firefox, ie, chrome, phantomjs, htmlunit, htmlunitwithjavascript, android, ipad, opera</param> /// <param name="version">Browser version</param> /// <param name="platform">Platform: WINDOWS, LINUX, MAC, ANDROID...</param> /// <example> /// <code lang="vbs"> /// Dim driver As New WebDriver() /// driver.StartRemotely "http://localhost:4444/wd/hub", "ie", 11 /// driver.Get "/" /// </code> /// </example> public void StartRemotely(string executorUri, string browser = null, string version = null, string platform = null) { try { browser = ExpendBrowserName(browser); switch (browser) { case "firefox": FirefoxDriver.ExtendCapabilities(this, true); break; case "chrome": ChromeDriver.ExtendCapabilities(this, true); break; case "phantomjs": PhantomJSDriver.ExtendCapabilities(this, true); break; case "internet explorer": IEDriver.ExtendCapabilities(this, true); break; case "MicrosoftEdge": EdgeDriver.ExtendCapabilities(this, true); break; case "opera": OperaDriver.ExtendCapabilities(this, true); break; } this.Capabilities.Platform = platform; this.Capabilities.BrowserName = browser; if (!string.IsNullOrEmpty(version)) { this.Capabilities.BrowserVersion = version; } _session = new RemoteSession(executorUri, false, this.timeouts); _session.Start(this.Capabilities); RegisterRunningObject(); } catch (SeleniumException) { throw; } catch (Exception ex) { throw new SeleniumException(ex); } }
internal Cookie(RemoteSession session, Dictionary dict) { _session = session; try { _name = dict.GetValue("name", string.Empty); _value = dict.GetValue("value", string.Empty); _path = dict.GetValue("path", string.Empty); _domain = dict.GetValue("domain", string.Empty); _secure = Convert.ToBoolean(dict.Get("secure", false)); _expiry = Convert.ToDouble(dict.Get("expiry", 0)); } catch (Errors.KeyNotFoundError ex) { throw new DeserializeException(typeof(Cookie), ex); } catch (Exception ex) { throw new SeleniumException(ex); } }
public bool CanReach(RemoteSession session, string remoteUri, TimeSpan timeout) { CouchbaseLiteHttpClientFactory.SetupSslCallback(); var uri = new Uri(remoteUri); try { using (var c = new TcpClient(uri.Host, uri.Port)) { return(true); } } catch (Exception e) { Log.To.Sync.I(TAG, "Didn't get successful connection to {0}", remoteUri); Log.To.Sync.V(TAG, " Cause: ", e); LastError = e; return(false); } }
/// <summary> /// Adds a new cookie. /// </summary> /// <param name="session"></param> /// <param name="name"></param> /// <param name="value"></param> /// <param name="path"></param> /// <param name="domain"></param> /// <param name="expiry"></param> /// <param name="secure"></param> /// <param name="httpOnly"></param> internal static void AddOne(RemoteSession session, string name, string value, string path, string domain, string expiry, bool secure, bool httpOnly) { var dict = new Dictionary(); dict.Add("name", name); dict.Add("value", value); if (path != null) dict.Add("path", path); if (domain != null) dict.Add("domain", domain); if (expiry != null) { var dt = (long)(DateTime.Parse(expiry) - Cookie.BASE_TIME).TotalSeconds; dict.Add("expiry", dt); } if (secure == true) dict.Add("secure", true); if (httpOnly == true) dict.Add("httpOnly", true); session.Send(RequestMethod.POST, "/cookie", "cookie", dict); }
internal static Alert SwitchToAlert(RemoteSession session, int timeout) { string text; try { text = (string)session.Send(RequestMethod.GET, "/alert_text"); } catch (Errors.NoAlertPresentError) { if (timeout == 0) throw; DateTime endTime = session.GetEndTime(timeout); while (true) { SysWaiter.Wait(); try { text = (string)session.SendAgain(); break; } catch (Errors.NoAlertPresentError) { if (DateTime.UtcNow > endTime) throw; } } } return new Alert(session, text); }
internal static string GetCurrentTitle(RemoteSession session) { return (string)session.Send(RequestMethod.GET, "/title"); }
internal JavascriptContext(RemoteSession session) { this.session = session; }
internal Timeouts(RemoteSession session) { _session = session; }
internal Mouse(RemoteSession session) { _session = session; }
/// <summary> /// Delete the cookie matching the name on the current page. /// </summary> /// <returns>object</returns> internal static void DeleteByName(RemoteSession session, string name) { session.Send(RequestMethod.DELETE, "/cookie/" + name); }
/// <summary>Get the default SSH session</summary> /// <returns>a remote session</returns> /// <exception cref="NGit.Errors.TransportException">in case of error with opening SSH session /// </exception> protected internal virtual RemoteSession GetSession() { if (sock != null) { return sock; } int tms = GetTimeout() > 0 ? GetTimeout() * 1000 : 0; sock = sch.GetSession(uri, GetCredentialsProvider(), local.FileSystem, tms); return sock; }
public override void Close() { if (sock != null) { try { sch.ReleaseSession(sock); } finally { sock = null; } } }
internal static string GetWindowHandle(RemoteSession session) { return (string)session.Send(RequestMethod.GET, "/window_handle"); }
/// <summary> /// Contructor over a session /// </summary> /// <param name="session"></param> internal FrameContext(RemoteSession session) { _session = session; }
/// <summary>Close (or recycle) a session to a host.</summary> /// <remarks>Close (or recycle) a session to a host.</remarks> /// <param name="session"> /// a session previously obtained from this factory's /// <see cref="GetSession(URIish, CredentialsProvider, NGit.Util.FS, int)">GetSession(URIish, CredentialsProvider, NGit.Util.FS, int) /// </see> /// method. /// </param> public virtual void ReleaseSession(RemoteSession session) { session.Disconnect(); }
internal Alert(RemoteSession session, string text) { _session = session; _text = text; }
internal TouchScreen(RemoteSession session) { _session = session; }
//private IME _ime; internal Manage(RemoteSession session) { _session = session; }
internal Actions(RemoteSession session) { _session = session; _mouse = session.mouse; _keyboard = session.keyboard; _actions = new List<Action>(); }
internal static string ActivateWindow(RemoteSession session, string name) { session.Send(RequestMethod.POST, "/window", "name", name); return (string)session.Send(RequestMethod.GET, "/window_handle"); }
internal static List GetWindowsHandles(RemoteSession session) { return (List)session.Send(RequestMethod.GET, "/window_handles"); }