B4J Library Selenium Browser Automation - Create any Robot with Browser


Selenium WebDriver - Mastering Test Automation with Selenium

What is Selenium?
Selenium is an open source automated testing suite for web applications across different browsers and platforms. It is quite similar to HP Quick Test Professional (QTP) only that Selenium focuses on automating web-based applications.

Selenium is not just a single tool but a suite of software's, each catering to different testing needs of an organization.

Based on Selenium WebDrivers, this new Library for B4J can automate browsers and create any robot and get any information from websites.

And you can use with or Without UI

Step 1:
Download the library and dependencies and put in your B4J Library Folder



Step 2:
Download the ChromeDriver for your platform.
Can be used on Windows/Linux/MacOSX, just download correct driver for your platform on:


TIP: Inside the samples you already have ChromeDriver.exe for windows

Step 3:
Try the samples

Sample 1: (SampleNasdaq.zip) Open Nasdaq.com website and get the top stocks on market

Sample 2: (SampleOyster.zip) Open UK TLF website for retrieve Oysters card and balance from each one

Check with a few lines of code you can retrieve a table from nasdaq website
Dim objSelenium As Selenium
objSelenium.DebugMode = True
Dim lstElements As List = objSelenium.findElementList("indexTable")
For Each k As String In lstElements

Check others libraries on:
Last edited:


Licensed User
Wee bit confused here.

Can I use this - for example:

Run this bot against my ( low powered VPS - web app (ABM) - stress test ) and determine what the maximum hit rate would be (before failure) - and what I need to upgrade the power of my VPS too (suggested)?

This has always been a concern for me, since I have no idea what "level" of VPS power I need to handle expected load. I start with cheapest, since it is only me testing.



Licensed User
It looks like a web scraping tool. Am I correct?


Licensed User
thanks for the quick response

link privacy from google ...
for example:

#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Dim objSelenium As Selenium
    Private robot As JavaObject
    Private Button1 As Button
    Private Button2 As Button
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("btn") 'Load the layout file.
    objSelenium.DebugMode = True

    Dim jo As JavaObject
    robot = jo.RunMethodJO("GetApplication",Null).RunMethodJO("createRobot",Null)
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub Button1_Click
    '//*[@id="fsr"]/a[1] <- from google copy xpath
    ' error : ->org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"id","selector":"//*[@id="fsr"]/a[1]"}
End Sub


Sub Button2_Click
    '/html/body/div/div[7]/div[1]/div/div/div/div/span[1]/a[1] <- from firefox copy xpath
    ' error : ->org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"id","selector":"/html/body/div/div[7]/div[1]/div/div/div/div/span[1]/a[1]"}
End Sub

apr 23, 2019 1:33:47 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFORMAZIONI: Detected dialect: OSS
[Java][DEMO] Remember this is a demo version of this library, please consider buy me a coffe. Paypal: alberto@vnsoft.es
[Java][DEMO] Remember this is a demo version of this library, please consider buy me a coffe. Paypal: alberto@vnsoft.es
Errore nella linea: 49 (Main)
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"id","selector":"/html/body/div/div[7]/div[1]/div/div/div/div/span[1]/a[1]"}
  (Session info: chrome=73.0.3683.103)
  (Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:05:20.749Z'
System info: host: 'DESKTOP-E1RMGQ1', ip: '', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 73.0.3683.68 (47787ec04b6e3..., userDataDir: C:\Users\Marcy\AppData\Loca...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:54876}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 73.0.3683.103, webStorageEnabled: true}
Session ID: 650a3682eff78d20532e7d9d1eede32d
*** Element info: {Using=id, value=/html/body/div/div[7]/div[1]/div/div/div/div/span[1]/a[1]}
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

Alberto Iglesias

Well-Known Member
Licensed User
@marcellissimo Hello my friend, sorry, I receive just today your message.

You right, find by xpath I found one bug on library and I already fixed on version v1.0.1


but for me, the xpath is:

Check this video:


Licensed User
I tested both buttons are working now. Thanks for the example.
Sub Button1_Click
    '//*[@id="fsr"]/a[1] <- from google copy xpath
End Sub

Sub Button2_Click
    '/html/body/div/div[7]/div[1]/div/div/div/div/span[1]/a[1] <- from firefox copy xpath
End Sub


Well-Known Member
Licensed User
Alberto, the SendKeys function seems to want the element name and not the id. Can you please add a second method for SendKeys by ID?