/// <summary> /// Selects the combo box item with specified text. /// </summary> /// <param name="text">The text of the item to select.</param> /// <param name="milliseconds"> /// The timeout in milliseconds before setting the selected item. /// </param> /// <exception cref="InvalidOperationException"> /// Window where combo box is located is null. /// </exception> public void SelectItemByText(string text, int milliseconds) { if (browserWindow == null) { throw new InvalidOperationException("Window must be set before calling this method."); } InternetExplorer.RunScript(browserWindow, "var obj = window.$find('" + id + "');obj.toggleDropDown();"); Thread.Sleep(milliseconds); InternetExplorer.RunScript(browserWindow, "var obj = window.$find('" + id + "');obj.findItemByText('" + text + "').select();obj.hideDropDown();"); }
public void HtmlHyperlink_OnSharePoint2010_Succeeds() { var browserWindow = BrowserWindow.Launch("http://myasia/sites/sureba/Default.aspx"); BrowserWindowUnderTest.Authenticate("username", "passwd"); browserWindow.Find <HtmlHyperlink>(By.Id("idHomePageNewDocument")).Click(); var closeLink = browserWindow.Find <HtmlHyperlink>(By.SearchProperties("Title=Close;class=ms-dlgCloseBtn")); //clicking closeLink directly doesn't work as the maximizeLink is clicked due to the controls being placed too close to each other Mouse.Click(closeLink.SourceControl.GetChildren()[0].GetChildren()[0]); InternetExplorer.RunScript(browserWindow, @"STSNavigate2(event,'/sites/sureba/_layouts/SignOut.aspx');"); }
/// <summary> /// Run/evaluate JavaScript code in the DOM context. /// </summary> /// <param name="code">The JavaScript code.</param> protected void RunScript(string code) { var browserWindow = (BrowserWindow)SourceControl.TopParent; InternetExplorer.RunScript(browserWindow, code); }
/// <summary> /// Run/evaluate JavaScript code in the DOM context. /// </summary> /// <param name="code">The JavaScript code</param> public void RunScript(string code) { InternetExplorer.RunScript(this, code); }