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")); }
/// <summary> /// Simulates typing into the element. /// </summary> /// <param name="keysOrModifier">Sequence of keys or a modifier key(Control,Shift...) if the sequence is in keysToSendEx</param> /// <param name="keys">Optional - Sequence of keys if keysToSend contains modifier key(Control,Shift...)</param> /// <returns></returns> /// <example> /// To Send mobile to an element : /// <code lang="vbs"> /// driver.FindElementsById("id").sendKeys "mobile" /// </code> /// To Send ctrl+a to an element : /// <code lang="vbs"> /// driver.FindElementsById("id").sendKeys Keys.Control, "a" /// </code> /// </example> public WebElement SendKeys(string keysOrModifier, string keys = null) { var text = string.Concat(keysOrModifier, keys); if (text == null) { throw new ArgumentNullException("text", "text cannot be null"); } if (!_session.IsLocal && text.IndexOf(":/") != -1 && File.Exists(text)) { text = _session.UploadFile(text); } Send(RequestMethod.POST, "/value", "value", new string[] { text }); return(this); }