B4J Library Selenium Library - Pnd_Selenium

Selenium automates browsers. That's it!
What you do with that power is entirely up to you.
Primarily it is for automating web applications for testing purposes, but is certainly not limited to just that.
Boring web-based administration tasks can (and should) also be automated as well.

Wrapper is based on selenium-java v4.7.0

Pnd_Selenium

Author: Author: selenium.dev - B4j Wrapper: Pendrush
Version: 0.5
  • Pnd_DataWebElement
    • Properties:
      • AccessibleName As String [read only]
        Getsa result of a Accessible Name and Description Computation for the Accessible Name of the element.
        See W3C WebDriver specification for more details.
        Returns: The accessible name of the element.
      • AriaRole As String [read only]
        Gets result of computing the WAI-ARIA role of element.
        See W3C WebDriver specification for more details.
        Returns: The WAI-ARIA role of the element.
      • Attribute As String [read only]
        Get the value of the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded.
        More exactly, this method will return the value of the property with the given name, if it exists.
        If it does not, then the value of the attribute with the given name is returned. If neither exists, null is returned.
        The "style" attribute is converted as best can be to a text representation with a trailing semicolon.
        The following are deemed to be "boolean" attributes, and will return either "true" or null:
        async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked,
        defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable,
        ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate,
        readonly, required, reversed, scoped, seamless, seeking, selected, truespeed, willvalidate.
        Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected:
        If the given name is "class", the "className" property is returned.
        If the given name is "readonly", the "readOnly" property is returned.
        Note: The reason for this behavior is that users frequently confuse attributes and properties.
        See W3C WebDriver specification for more details.
      • Displayed As Boolean [read only]
        Is this element displayed or not? This method avoids the problem of having to parse an element's "style" attribute.
        Returns: Whether the element is displayed.
      • Enabled As Boolean [read only]
        Is the element currently enabled or not? This will generally return true for everything but disabled input elements.
        See W3C WebDriver specification for more details.
        Returns: True if the element is enabled, false otherwise.
      • Rect As String [read only]
        Returns: The location and size of the rendered element. (X, Y, Height, Width)
        See W3C WebDriver specification for more details.
        X = X axis position of the top-left corner of the web element relative to the current browsing context’s document element in CSS pixels.
        Y = Y axis position of the top-left corner of the web element relative to the current browsing context’s document element in CSS pixels.
        Height = Height of the web element’s bounding rectangle in CSS pixels.
        Width = Width of the web element’s bounding rectangle in CSS pixels.
      • Selected As Boolean [read only]
        Determine whether this element is selected or not.
        This operation only applies to input elements such as checkboxes, options in a select and radio buttons.
        For more information on which elements this method supports, refer to the specification.
        See W3C WebDriver specification for more details.
        Returns: True if the element is currently selected or checked, false otherwise.
      • TagName As String [read only]
        Get the tag name of this element. Not the value of the name attribute: will return "input" for the element .
        See W3C WebDriver specification for more details.
        Returns: The tag name of this element.
      • Text As String [read only]
        Get the visible (i.e. not hidden by CSS) text of this element, including sub-elements.
        See W3C WebDriver specification for more details.
        Returns: The visible text of this element.
  • Pnd_Selenium
    • Events:
      • GetFinished
    • Functions:
      • ActionSendNonTextKey (key As Int)
        All non text keys.
      • AddArgument (Argument As String)
        Argument – The arguments to use when starting Chrome
        List of possible Arguments.
        Selenium.AddArgument("--start-maximized")
      • Close
        Close the current window, quitting the browser if it's the last window currently open.
        See W3C WebDriver specification for more details.
      • CurrentUrl As String
        Get a string representing the current URL that the browser is looking at.
        See W3C WebDriver specification for more details.
        Returns: The URL of the page currently loaded in the browser
      • FindByClassNameList (ClassName As String, Attribute As String) As List
        Find all elements within the current page using Class Name.
        Attribute – The name of the attribute. Pass "" (empty string) if you dont need attribute.
        Get the value of the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded.
        More exactly, this method will return the value of the property with the given name, if it exists.
        If it does not, then the value of the attribute with the given name is returned. If neither exists, null is returned.
        The "style" attribute is converted as best can be to a text representation with a trailing semicolon.
        The following are deemed to be "boolean" attributes, and will return either "true" or null:
        async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked,
        defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable,
        ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate,
        readonly, required, reversed, scoped, seamless, seeking, selected, truespeed, willvalidate.
        Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected:
        If the given name is "class", the "className" property is returned.
        If the given name is "readonly", the "readOnly" property is returned.
        Note: The reason for this behavior is that users frequently confuse attributes and properties.
        See W3C WebDriver specification for more details.
        This method is affected by the 'implicit wait' times in force at the time of execution.
        When implicitly waiting, this method will return as soon as there are more than 0 items in the found collection, or will return an empty list if the timeout is reached.
        See W3C WebDriver specification for more details.
        Returns: List of Pnd_DataWebElement
      • FindByClassNameWebElement (ClassName As String) As org.openqa.selenium.WebElement
        Find element within the current page using Class Name.
        Returns: Object of WebElement
      • FindByCssSelectorList (CssSelector As String, Attribute As String) As List
        Find elements via the driver's underlying W3C Selector engine.
        If the browser does not implement the Selector API, a best effort is made to emulate the API.
        In this case, we strive for at least CSS2 support, but offer no guarantees.
        CssSelector – CSS expression.
        Attribute – The name of the attribute. Pass "" (empty string) if you dont need attribute.
        Get the value of the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded.
        More exactly, this method will return the value of the property with the given name, if it exists.
        If it does not, then the value of the attribute with the given name is returned. If neither exists, null is returned.
        The "style" attribute is converted as best can be to a text representation with a trailing semicolon.
        The following are deemed to be "boolean" attributes, and will return either "true" or null:
        async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked,
        defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable,
        ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate,
        readonly, required, reversed, scoped, seamless, seeking, selected, truespeed, willvalidate.
        Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected:
        If the given name is "class", the "className" property is returned.
        If the given name is "readonly", the "readOnly" property is returned.
        Note: The reason for this behavior is that users frequently confuse attributes and properties.
        See W3C WebDriver specification for more details.
        Returns: List of Pnd_DataWebElement
      • FindByCssSelectorWebElement (CssSelector As String) As org.openqa.selenium.WebElement
        Find elements via the driver's underlying W3C Selector engine.
        If the browser does not implement the Selector API, a best effort is made to emulate the API.
        In this case, we strive for at least CSS2 support, but offer no guarantees.
        CssSelector – CSS expression.
        Returns: Object of WebElement
      • FindByIDList (Id As String, Attribute As String) As List
        Find all elements within the current page using ID.
        Attribute – The name of the attribute. Pass "" (empty string) if you dont need attribute.
        Get the value of the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded.
        More exactly, this method will return the value of the property with the given name, if it exists.
        If it does not, then the value of the attribute with the given name is returned. If neither exists, null is returned.
        The "style" attribute is converted as best can be to a text representation with a trailing semicolon.
        The following are deemed to be "boolean" attributes, and will return either "true" or null:
        async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked,
        defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable,
        ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate,
        readonly, required, reversed, scoped, seamless, seeking, selected, truespeed, willvalidate.
        Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected:
        If the given name is "class", the "className" property is returned.
        If the given name is "readonly", the "readOnly" property is returned.
        Note: The reason for this behavior is that users frequently confuse attributes and properties.
        See W3C WebDriver specification for more details.
        This method is affected by the 'implicit wait' times in force at the time of execution.
        When implicitly waiting, this method will return as soon as there are more than 0 items in the found collection, or will return an empty list if the timeout is reached.
        See W3C WebDriver specification for more details.
        Returns: List of Pnd_DataWebElement
      • FindByIdWebElement (Id As String) As org.openqa.selenium.WebElement
        Find element within the current page using ID.
        Returns: Object of WebElement
      • FindByLinkTextList (LinkText As String, Attribute As String) As List
        FindByLinkText works on the link text as you see it with your eyes on the website (after all CSS is applied), not by the website source code.
        LinkText – The exact text to match against.
        Attribute – The name of the attribute. Pass "" (empty string) if you dont need attribute.
        Get the value of the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded.
        More exactly, this method will return the value of the property with the given name, if it exists.
        If it does not, then the value of the attribute with the given name is returned. If neither exists, null is returned.
        The "style" attribute is converted as best can be to a text representation with a trailing semicolon.
        The following are deemed to be "boolean" attributes, and will return either "true" or null:
        async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked,
        defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable,
        ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate,
        readonly, required, reversed, scoped, seamless, seeking, selected, truespeed, willvalidate.
        Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected:
        If the given name is "class", the "className" property is returned.
        If the given name is "readonly", the "readOnly" property is returned.
        Note: The reason for this behavior is that users frequently confuse attributes and properties.
        See W3C WebDriver specification for more details.
        Returns: List of Pnd_DataWebElement
      • FindByLinkTextWebElement (LinkText As String) As org.openqa.selenium.WebElement
        FindByLinkText works on the link text as you see it with your eyes on the website (after all CSS is applied), not by the website source code.
      • FindByPartialLinkTextList (PartialLinkText As String, Attribute As String) As List
        FindByPartialLinkText works on the link text as you see it with your eyes on the website (after all CSS is applied), not by the website source code.
        PartialLinkText – The partial text to match against.
        Attribute – The name of the attribute. Pass "" (empty string) if you dont need attribute.
        Get the value of the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded.
        More exactly, this method will return the value of the property with the given name, if it exists.
        If it does not, then the value of the attribute with the given name is returned. If neither exists, null is returned.
        The "style" attribute is converted as best can be to a text representation with a trailing semicolon.
        The following are deemed to be "boolean" attributes, and will return either "true" or null:
        async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked,
        defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable,
        ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate,
        readonly, required, reversed, scoped, seamless, seeking, selected, truespeed, willvalidate.
        Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected:
        If the given name is "class", the "className" property is returned.
        If the given name is "readonly", the "readOnly" property is returned.
        Note: The reason for this behavior is that users frequently confuse attributes and properties.
        See W3C WebDriver specification for more details.
        Returns: List of Pnd_DataWebElement
      • FindByPartialLinkTextWebElement (PartialLinkText As String) As org.openqa.selenium.WebElement
        FindByPartialLinkText works on the link text as you see it with your eyes on the website (after all CSS is applied), not by the website source code.
        PartialLinkText – The partial text to match against.
        Returns: Object of WebElement
      • FindByTagNameList (TagName As String, Attribute As String) As List
        TagName – The element's tag name.
        Attribute – The name of the attribute. Pass "" (empty string) if you dont need attribute.
        Get the value of the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded.
        More exactly, this method will return the value of the property with the given name, if it exists.
        If it does not, then the value of the attribute with the given name is returned. If neither exists, null is returned.
        The "style" attribute is converted as best can be to a text representation with a trailing semicolon.
        The following are deemed to be "boolean" attributes, and will return either "true" or null:
        async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked,
        defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable,
        ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate,
        readonly, required, reversed, scoped, seamless, seeking, selected, truespeed, willvalidate.
        Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected:
        If the given name is "class", the "className" property is returned.
        If the given name is "readonly", the "readOnly" property is returned.
        Note: The reason for this behavior is that users frequently confuse attributes and properties.
        See W3C WebDriver specification for more details.
        Returns: List of Pnd_DataWebElement
      • FindByTagNameWebElement (TagName As String) As org.openqa.selenium.WebElement
        TagName – The element's tag name.
        Returns: Object of WebElement
      • FindByXPathList (Path As String, Attribute As String) As List
        Path – The XPath to use.
        Attribute – The name of the attribute. Pass "" (empty string) if you dont need attribute.
        Get the value of the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded.
        More exactly, this method will return the value of the property with the given name, if it exists.
        If it does not, then the value of the attribute with the given name is returned. If neither exists, null is returned.
        The "style" attribute is converted as best can be to a text representation with a trailing semicolon.
        The following are deemed to be "boolean" attributes, and will return either "true" or null:
        async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked,
        defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable,
        ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate,
        readonly, required, reversed, scoped, seamless, seeking, selected, truespeed, willvalidate.
        Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected:
        If the given name is "class", the "className" property is returned.
        If the given name is "readonly", the "readOnly" property is returned.
        Note: The reason for this behavior is that users frequently confuse attributes and properties.
        See W3C WebDriver specification for more details.
        Returns: List of Pnd_DataWebElement
      • FindByXpathWebElement (Path As String) As org.openqa.selenium.WebElement
        Path – The XPath to use.
        Returns: Object of WebElement
      • Get (Url As String)
        Load a new web page in the current browser window.
        This is done using an HTTP POST operation, and the method will block until the load is complete with the default 'page load strategy'.
        This will follow redirects issued either by the server or as a meta-redirect from within the returned HTML.
        Should a meta-redirect "rest" for any duration of time, it is best to wait until this timeout is over,
        since should the underlying page change whilst your test is executing the results of future calls against this interface will be against the freshly loaded page.
        See W3C WebDriver specification for more details.
      • Initialize (EventName As String, ChromeDriverPath As String)
        ChromeDriverPath - Path to Chrome driver

        Selenium.Initialize("Selenium", "c:\ChromeDriver\chromedriver.exe")
      • PageSource As String
        Get the source of the last loaded page.
        If the page has been modified after loading (for example, by Javascript)
        there is no guarantee that the returned text is that of the modified page.
        Please consult the documentation of the particular driver being used to determine whether the returned text
        reflects the current state of the page or the text last sent by the web server.
        The page source returned is a representation of the underlying DOM: do not expect it to be formatted or escaped
        in the same way as the response sent from the web server. Think of it as an artist's impression.
        See W3C WebDriver specification for more details.
        Returns: The source of the current page.
      • Quit
        Quits, closing every associated window.
      • SwitchToFrame (NameOrID As String)
        Select a frame by its Name or ID. Frames located by matching name attributes are always given precedence over those matched by ID.
        Params: NameOrID – the name of the frame window, the id of the frame or iframe element, or the (zero-based) index.
      • SwitchToParentFrame
        Change focus to the parent context. If the current context is the top level browsing context, the context remains unchanged.
        See W3C WebDriver specification for more details.
      • Title As String
        Get the title of the current page.
        See W3C WebDriver specification for more details.
        Returns: The title of the current page, with leading and trailing whitespace stripped, or null if one is not already set
      • WebElementClear (WebElement As org.openqa.selenium.WebElement)
        If this element is a form entry element, this will reset its value.
        See W3C WebDriver specification for more details.
      • WebElementClick (WebElement As org.openqa.selenium.WebElement)
        Click this element. If this causes a new page to load, you should discard all references to this element
        and any further operations performed on this element will throw a StaleElementReferenceException.
        Note that if click() is done by sending a native event (which is the default on most browsers/platforms)
        then the method will _not_ wait for the next page to load and the caller should verify that themselves.
        There are some preconditions for an element to be clicked.
        The element must be visible, and it must have a height and width greater than 0.
        See W3C WebDriver specification for more details.
      • WebElementSendKeys (WebElement As org.openqa.selenium.WebElement, Keys As String)
        Use this method to simulate typing into an element, which may set its value.
        See W3C WebDriver specification for more details.
        Params: Keys – character sequence to send to the element
      • WebElementSubmit (WebElement As org.openqa.selenium.WebElement)
        If this current element is a form, or an element within a form, then this will be submitted to the remote server.
        If this causes the current page to change, then this method will block until the new page is loaded.
Download library from: https://www.dropbox.com/s/voy1d15ne0w0ju9/SeleniumLibrary.zip?dl=0
Download Chrome Driver for your OS from: https://chromedriver.chromium.org/downloads
Tested with (chromedriver_win32.zip): https://chromedriver.storage.googleapis.com/index.html?path=108.0.5359.71/
 

Attachments

  • SeleniumExample.zip
    2.2 KB · Views: 23
Top