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.9.1

Pnd_Selenium

Author:
Author: selenium.dev - B4j Wrapper: Pendrush
Version: 0.61
  • 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")
      • AllTabs As List
        Returns: string List of all tabs
      • 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
      • ExecuteScript (JsScript As String, WebElement As org.openqa.selenium.WebElement)
        Executes JavaScript in the context of the currently selected frame or window. The script fragment provided will be executed as the body of an anonymous function.
      • 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.
      • SwitchToTab (Name As String)
        Switch the focus of future commands for this driver to the window/tab with the given name.
      • TakeScreenshotToFile (Format As String, Path As String)
        Capture the screenshot (only visible part of the page) and store it in the specified location.
        Format - "png" or "jpg"
        Path - "c:\test.jpg"
        Selenium.TakeScreenshotToFile("jpg", "c:\test.jpg")
      • 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.

v0.61
  • ExecuteScript (JavaScript)
  • New example app
  • Selenium upgrade to v4.9.1

v0.6
  • Screenshots
  • Switch to tab
  • New example app

v0.5
  • Initial release

Download library from: https://www.dropbox.com/s/equzw5atcjn9e17/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.4 KB · Views: 309
Last edited:

Pip

Member
Hi Pendrush,

first of all, thanks a lot for this Selenium library !

I only despair at the moment with Chrome's automation, after pressing a button opens a new tab and thus the CurrentUrl is no longer correct.

Thus the question: "How can I set the focus on the new TAB and thus continue to work in it?"

Thanks in advance !

With kind regards
Pip
 

Pendrush

Well-Known Member
Licensed User
Longtime User
Library updated to v0.6, to switch tab use code:
B4X:
Dim TabName As String
For Each name As String In Selenium.AllTabs
    TabName = name
Next
Selenium.SwitchToTab(TabName)
 

Pip

Member
Hi Pendrush,

the change to the new TAB works only conditionally. The CurrentURL changes apparently, but certain elements on this TAB are unfortunately still not findable.

As an example:
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method": "css selector", "selector": "body#body>header>form>div>div>button"}

it doesn't matter if I search with CSS selector or XPath, the element remains untraceable.

Even if I close the old TAB before executing the For Each loop, this has no effect.

I try to address a textbox and next a button. Despite the correct linking I get "No Search element" displayed. It seems to me that the website blocks such controls.

Try:
By simulating the Tab key, I navigate to the textbox and would now only need a routine to pass a text, unfortunately I am missing the element here and pure keyboard input cannot be sent, also CTRL+V fails unfortunately.

Would you still have an idea for me ?
 

Pip

Member
Sorry for double post,

is there a way to disable the message "Chrome is being controlled by automated test software" and suggest to the web server that there is no underlying automation? I have not been able to solve it via startup parameters.

As an example:
I try to log in to the UPS website, automated by Chromedriver I get an "Access Denied" message.

So I would have to make it so that the web server does not notice that it is an automation software. Is there a solution for this problem?

Thanks a lot in advance !
 
Last edited:

Anser

Well-Known Member
Licensed User
Longtime User
certain elements on this TAB are unfortunately still not findable.

As an example:
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method": "css selector", "selector": "body#body>header>form>div>div>button"}

it doesn't matter if I search with CSS selector or XPath, the element remains untraceable.
Maybe the elements that you are trying to access are inside a Frame.
Switch to that particular frame first using the SwitchToFrame() and then try to access those elements
 

Pip

Member
Maybe the elements that you are trying to access are inside a Frame.
Switch to that particular frame first using the SwitchToFrame() and then try to access those elements
SwitchToFrame() was a good hint ! Thank you, I could then access the element via XPath !

Ok, so this works now, but how do I solve the problem that the UPS website (completely different website) recognizes that it is an automation ? Do you have a tip for me ?

Thank you :)
 

Pendrush

Well-Known Member
Licensed User
Longtime User
Maybe you can try to change user agent, for example:
B4X:
Selenium.AddArgument("--user-agent=Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)")
You can also try some other user agent from different browsers.
 

Pip

Member
Maybe you can try to change user agent, for example:
B4X:
Selenium.AddArgument("--user-agent=Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)")
You can also try some other user agent from different browsers.
Hello Pendrush,

I had
B4X:
Selenium.AddArgument("--user-agent=Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)")
tested once via https://botcheck.luminati.io/ with the following result:
Navigate type
FAIL user-agent: missing user-agent header

Other test with
B4X:
Selenium.AddArgument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36")
gave the following:

Navigate type
PASS user agent
WARN header values warn: sent headers do not match expectations
accept-language
+ de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
- en-US,en;q=0.9
FAIL header values: sent headers do not match what is expected
accept
+ text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
- text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
WARN Tricky headers: incorrect use of these headers may affect success rate
- sec-fetch-site
- sec-fetch-mode
- sec-fetch-user
- sec-fetch-dest
FAIL Unexpected headers
- sec-ch-ua: "Chromium";v="110", "Not A(brand";v="24", "Google Chrome";v="110"
- sec-ch-ua-mobile: ?0
- sec-ch-ua-platform: "Windows
PASS header case
PASS header order
PASS HTTP version
FAIL TLS version
+ TLSv1.3
- TLSv1.2
FAIL TLS Encryption
+ 5a5a130113021303c02bc02fc02cc030cca9cca8c013c014009c009d002f0035
FAIL Http2 settings
enablePush
+ false
- true
maxHeaderListSize
+ 262144
- 4294967295
maxHeaderSize
+ 262144
- undefined

Both attempts ended in "Access Denied" so far. I will test more user agents.
 

Pendrush

Well-Known Member
Licensed User
Longtime User
Maybe:
B4X:
Selenium.AddArgument("-–disable-blink-features=AutomationControlled")
 

kostefar

Active Member
Licensed User
Longtime User
I hope this thread is not too old to add a bit to it. If so, please let me know, and I´ll start a new one.

I´ve installed Selenium, but fail to get the demo working. I´m using the latest chromedriver, which is 111.0.5563.65, whereas the chromedriver is for 111.0.5563.64, so not sure if that´s what´s causing the below:


B4X:
WARNING: package com.sun.javafx.embed.swing.oldimpl not in javafx.swing
Waiting for debugger to connect...
Program started.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Starting ChromeDriver 111.0.5563.64 (c710e93d5b63b7095afe8c2c17df34408078439d-refs/branch-heads/5563@{#995}) on port 14376
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
mar. 15, 2023 3:13:57 PM org.openqa.selenium.remote.http.WebSocket$Listener onError
WARNING: Invalid Status code=403 text=Forbidden
java.io.IOException: Invalid Status code=403 text=Forbidden
    at org.asynchttpclient.netty.handler.WebSocketHandler.abort(WebSocketHandler.java:92)
    at org.asynchttpclient.netty.handler.WebSocketHandler.handleRead(WebSocketHandler.java:118)
    at org.asynchttpclient.netty.handler.AsyncHttpClientHandler.channelRead(AsyncHttpClientHandler.java:78)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:336)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:444)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:280)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:832)
Error occurred on line: 24 (Main)
org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to http://localhost:53946/devtools/browser/372efec7-19e0-4f6b-9c7f-ede143289bf0
Build info: version: '4.7.2', revision: '4d4020c3b7'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '14.0.1'
Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.remote.http.netty.NettyWebSocket.<init>(NettyWebSocket.java:102)
    at org.openqa.selenium.remote.http.netty.NettyWebSocket.lambda$create$3(NettyWebSocket.java:128)
    at org.openqa.selenium.remote.http.netty.NettyClient.openSocket(NettyClient.java:107)
    at org.openqa.selenium.devtools.Connection.<init>(Connection.java:78)
    at org.openqa.selenium.chromium.ChromiumDriver.lambda$new$2(ChromiumDriver.java:116)
    at java.base/java.util.Optional.map(Optional.java:258)
    at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:114)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:82)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:71)
    at com.pendrush.selenium.kotlin.SeleniumLib.initialize(SeleniumLib.kt:32)
    at com.pendrush.selenium.Wrapper.initialize2(Wrapper.java:39)
    at com.pendrush.selenium.Wrapper.Initialize(Wrapper.java:35)
    at b4j.example.main._appstart(main.java:78)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at b4j.example.main.start(main.java:38)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:832)

Thanks in advance!
 

Pip

Member
I hope this thread is not too old to add a bit to it. If so, please let me know, and I´ll start a new one.

I´ve installed Selenium, but fail to get the demo working. I´m using the latest chromedriver, which is 111.0.5563.65, whereas the chromedriver is for 111.0.5563.64, so not sure if that´s what´s causing the below:


B4X:
WARNING: package com.sun.javafx.embed.swing.oldimpl not in javafx.swing
Waiting for debugger to connect...
Program started.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Starting ChromeDriver 111.0.5563.64 (c710e93d5b63b7095afe8c2c17df34408078439d-refs/branch-heads/5563@{#995}) on port 14376
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
mar. 15, 2023 3:13:57 PM org.openqa.selenium.remote.http.WebSocket$Listener onError
WARNING: Invalid Status code=403 text=Forbidden
java.io.IOException: Invalid Status code=403 text=Forbidden
    at org.asynchttpclient.netty.handler.WebSocketHandler.abort(WebSocketHandler.java:92)
    at org.asynchttpclient.netty.handler.WebSocketHandler.handleRead(WebSocketHandler.java:118)
    at org.asynchttpclient.netty.handler.AsyncHttpClientHandler.channelRead(AsyncHttpClientHandler.java:78)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:336)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:444)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:280)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:832)
Error occurred on line: 24 (Main)
org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to http://localhost:53946/devtools/browser/372efec7-19e0-4f6b-9c7f-ede143289bf0
Build info: version: '4.7.2', revision: '4d4020c3b7'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '14.0.1'
Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.remote.http.netty.NettyWebSocket.<init>(NettyWebSocket.java:102)
    at org.openqa.selenium.remote.http.netty.NettyWebSocket.lambda$create$3(NettyWebSocket.java:128)
    at org.openqa.selenium.remote.http.netty.NettyClient.openSocket(NettyClient.java:107)
    at org.openqa.selenium.devtools.Connection.<init>(Connection.java:78)
    at org.openqa.selenium.chromium.ChromiumDriver.lambda$new$2(ChromiumDriver.java:116)
    at java.base/java.util.Optional.map(Optional.java:258)
    at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:114)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:82)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:71)
    at com.pendrush.selenium.kotlin.SeleniumLib.initialize(SeleniumLib.kt:32)
    at com.pendrush.selenium.Wrapper.initialize2(Wrapper.java:39)
    at com.pendrush.selenium.Wrapper.Initialize(Wrapper.java:35)
    at b4j.example.main._appstart(main.java:78)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at b4j.example.main.start(main.java:38)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:832)

Thanks in advance!

Hey kostefar,

Try this before Selenium.initialize:
B4X:
Selenium.addArgument("--remote-allow-origins=*")

It works fine for me !

Kind regards
Pip
 

kostefar

Active Member
Licensed User
Longtime User
Hey kostefar,

Try this before Selenium.initialize:
B4X:
Selenium.addArgument("--remote-allow-origins=*")

It works fine for me !

Kind regards
Pip
Thank you SO much Pip, now I´m one step further! How did you find out about that?
 

Pip

Member

Pip

Member
@Pendrush

Is there a possibility to set the "navigator.webdriver" flag to false ?

The Chromedriver starts with navigator.webdriver = true, so the website already knows about it. This flag would be false if the website is driven by a human.

Is it possible to make the chrome dev options accessible before the chrome browser starts and thus set the flag to false ?

If this already works with the current library, I wouldn't know exactly how to do it.

Thanks in advance !
 

syerif

Active Member
Licensed User
Longtime User
1680255246177.png


Hi,
it is possible with your library to scrolling browser like this..

Thank you
 

kostefar

Active Member
Licensed User
Longtime User
Would someone be able to get me started on something that looks like this in terms of filling in email address + password and clicking "Sign in"?

B4X:
<div class="form-group username">
            <label class="control-label" for="Email">Email</label>
            <input class="form-control" placeholder="Email Address" autocomplete="off" tabindex="1" spellcheck="false" type="text" data-val="true" data-val-required="The Email field is required." id="Email" name="Email" value="" />
            <span class="text-danger" id="unError" style="display:none;">Please enter a valid email address</span>
        </div>
            <div class="form-group password">
                <label class="control-label" for="Password">Password</label>
                <input type="password" class="form-control" placeholder="Password" autofocus="autofocus" autocomplete="off" tabindex="2" id="Password" name="Password" />
            </div>

        <div class="form-group">
            <label class="chk-label" for="RememberLogin">
                <input tabindex="4" type="checkbox" checked="checked" data-val="true" data-val-required="The Remember Login field is required." id="RememberLogin" name="RememberLogin" value="true" />
                Remember Login
            </label>
        </div>

        <div class="form-group">
            <button type="submit" id="SubmitLogin" tabindex="3">
                Sign in
            </button>
        </div>

Thanks in advance!

PS: I did already try different things using the example attached to the initial post as a template, but with no luck so far.
 
Last edited:

behnam_tr

Active Member
Licensed User
Longtime User
@Pendrush
thanks for great library

please can you add method for execute java script code ??
i need to Modify innerHTML
like this :
B4X:
<span class="locked-step"></span>

to

<span class="showStepsButton"></span>

 
Top