示例#1
0
 /// <summary>
 /// Write into the HTML element (usually a text input) with the given id, per default discrete.
 /// Wait RequestTimeout seconds for the element to appear.
 /// </summary>
 /// <param name="id">HTML id attribute of the element to click on</param>
 /// <param name="text">Text to write</param>
 /// <param name="wait">Explicit WebDriverWait in seconds  for the element to appear</param>
 /// <param name="throttle">Time interval in milliseconds between sending chars to a text input when > 0</param>
 public void Write(string id, string text,
                   int wait = 0, int throttle = 0)
 {
     SeleniumExtensionBase.WriteID(this, id, text,
                                   wait: (wait == 0) ? SeleniumExtensionBase.RequestTimeout : wait,
                                   throttle);
 }
示例#2
0
 /// <summary>
 /// Click the ASP.NET control element (usually a Button instance) directly and wait for the response
 /// when expectPostBack is true.
 /// </summary>
 /// <param name="control">The ASP.NET control to click on</param>
 /// <param name="expectPostBack">Whether to expect a server request from the click</param>
 /// <param name="samePage">Whether the PostBack stays on the same page with the same HTML element</param>
 /// <param name="expectedStatusCode">Expected StatusCode of the response</param>
 /// <param name="delay">Optional delay time in milliseconds before clicking the element</param>
 /// <param name="pause">Optional pause time in milliseconds after IE claims DocumentComplete</param>
 public static void Click(this ISelenium inst, Control control, bool expectPostBack = true, bool samePage = false,
                          int expectedStatusCode = 200, int delay = 0, int pause = 0)
 {
     SeleniumExtensionBase.ClickID(inst, control.ClientID,
                                   expectRequest: expectPostBack, samePage: samePage,
                                   expectedStatusCode: expectedStatusCode, delay: delay, pause: pause);
 }
示例#3
0
        /// <summary>
        /// Click the ASP.NET control element (usually a Button instance) at the given path and wait for the response
        /// when expectPostBack is true.
        /// </summary>
        /// <param name="path">Member name path to the control starting at the main control</param>
        /// <param name="expectPostBack">Whether to expect a server request from the click</param>
        /// <param name="samePage">Whether the PostBack stays on the same page with the same HTML element</param>
        /// <param name="expectedStatusCode">Expected StatusCofe of the response</param>
        /// <param name="delay">Optional delay time in milliseconds before clicking the element</param>
        /// <param name="pause">Optional pause time in milliseconds after IE claims DocumentComplete</param>
        public static void Click(this ISelenium inst, string path, bool expectPostBack = true, bool samePage = false,
                                 int expectedStatusCode = 200, int delay = 0, int pause = 0)
        {
            var button = GetControl(inst, path);

            SeleniumExtensionBase.ClickID(inst, button.ClientID,
                                          expectRequest: expectPostBack, samePage: samePage,
                                          expectedStatusCode: expectedStatusCode, delay: delay, pause: pause);
        }
示例#4
0
        /// <summary>
        /// Click the HTML element (usually a Button) with the given id and
        /// index, don't wait for a response as expectRequest defaults to false for an SPA,
        /// but wait RequestTimeout seconds for the element to appear.
        /// </summary>
        /// <param id="id">HTML id attribute of the element to click on</param>
        /// <param name="index">Index of the element collection with that id, defaults to 0</param>
        /// <param name="expectRequest">Whether to expect a GET/POST request to the server from the click</param>
        /// <param name="samePage">Whether to expect a WebForms style PostBack to the same page with the same HTML element</param>
        /// <param name="awaitRemoved">Whether to wait for the HTML element to disappear (in an SPA)</param>
        /// <param name="expectedStatusCode">Expected StatusCofe of the response</param>
        /// <param name="delay">Optional delay time in milliseconds before clicking the element</param>
        /// <param name="pause">Optional pause time in milliseconds after IE claims DocumentComplete</param>
        /// <param name="wait">Explicit WebDriverWait in seconds  for the element to appear</param>
        public void Click(string id, int index   = 0,
                          bool expectRequest     = false, bool?samePage = null, bool?awaitRemoved = null,
                          int expectedStatusCode = 200, int delay       = 0, int pause = 0, int wait = 0)
        {
            var doAwaitRemoved = awaitRemoved ?? this.awaitRemovedDefault;
            var onSamePage     = samePage ?? this.samePageDefault;

            SeleniumExtensionBase.ClickID(this, id, index,
                                          expectRequest: expectRequest, samePage: onSamePage,
                                          awaitRemoved: doAwaitRemoved, expectedStatusCode: expectedStatusCode,
                                          delay: delay, pause: pause,
                                          wait: (wait == 0) ? SeleniumExtensionBase.RequestTimeout : wait);
        }
示例#5
0
        /// <summary>
        /// Select the item with the given value from a ListControl and wait for the response
        /// when expectPostBack is true.
        /// </summary>
        /// <param name="path">Member name path to the control starting at the main control</param>
        /// <param name="value">value of the item to click on</param>
        /// <param name="expectPostBack">Whether to expect a server request from the click. Defaults to false</param>
        /// <param name="expectedStatusCode">Expected StatusCode of the response</param>
        /// <param name="delay">Optional delay time in milliseconds before clicking the element</param>
        /// <param name="pause">Optional pause time in milliseconds after IE claims DocumentComplete</param>
        public static void Select(this ISelenium inst, string path, string value, bool expectPostBack = false, int expectedStatusCode = 200, int delay = 0, int pause = 0)
        {
            var list = GetControl(inst, path) as ListControl;

            if (list == null)
            {
                throw new Exception(String.Format("ListControl at '{0}' not found", path));
            }
            for (int idx = 0; idx <= list.Items.Count; idx++)
            {
                if (idx == list.Items.Count)
                {
                    throw new Exception(String.Format("ListControl at '{0}': value '{1}' not found", path, value));
                }
                else if (list.Items[idx].Value == value)
                {
                    string itemID = String.Format("{0}_{1}", list.ClientID, idx);
                    SeleniumExtensionBase.ClickID(inst, itemID, expectRequest: expectPostBack, samePage: !expectPostBack,
                                                  expectedStatusCode: expectedStatusCode, delay: delay, pause: pause);
                    break;
                }
            }
        }
示例#6
0
 /// <summary>
 /// Get the HTML source of the page, wait RequestTimeout seconds for the body element to appear
 /// </summary>
 /// <param name="wait">Explicit WebDriverWait for the HTML to be rendered</param>
 /// <returns>HTML source</returns>
 public string Html(int wait = 0)
 {
     return(SeleniumExtensionBase.Html(this, wait: (wait == 0) ? SeleniumExtensionBase.RequestTimeout : wait));
 }
示例#7
0
 /// <summary>
 /// Get the element with the given id
 /// Wait RequestTimeout seconds for the element to appear.
 /// </summary>
 /// <param name="id">HTML id attribute of the elements</param>
 /// <param name="index">Index of the element collection with that name, defaults to 0</param>
 /// <param name="wait">Explicit WebDriverWait in seconds  for the element to appear</param>
 /// <returns></returns>
 public IWebElement GetHTMLElementById(string id, int index = 0, int wait = 0)
 {
     return(SeleniumExtensionBase.GetHTMLElementById(this, id, index,
                                                     wait: (wait == 0) ? SeleniumExtensionBase.RequestTimeout : wait));
 }
示例#8
0
 public static void TearDownIE(this ISeleniumBase inst)
 {
     SeleniumExtensionBase.TearDownBrowser(inst);
 }
示例#9
0
 public static void SetUpIE(this ISeleniumBase inst)
 {
     SeleniumExtensionBase.SetUpBrowser <InternetExplorerDriver>(inst);
 }
示例#10
0
 /// <summary>
 /// Get the element adapter with the given clientID
 /// </summary>
 /// <param name="clientID">ClientID resp. HTML id attribute of the element</param>
 /// <returns></returns>
 public static IWebElement GetHTMLElement(this ISelenium inst, string clientID)
 {
     return(SeleniumExtensionBase.GetHTMLElementById(inst, clientID));
 }
示例#11
0
        /// <summary>
        /// Write into the ASP.NET control (usually a TextBox instance) at the given path
        /// </summary>
        /// <param name="path">Member name path to the control starting at the main control</param>
        /// <param name="text">Text to write</param>
        /// <param name="throttle">Time interval in milliseconds between sending chars to a text input when > 0</param>
        public static void Write(this ISelenium inst, string path, string text, int throttle = 0)
        {
            var textinput = GetHTMLElement(inst, ControlRootExtension.GetRoot(), path);

            SeleniumExtensionBase.SendKeys(textinput, text, throttle);
        }