Skip to content

The project "autoit-webdriver-boilerplate" can be used as quick entry point for the awesome "au3WebDriver" project by @Danp2 (and @mlipok). The intention is, give people a easy start with WebDriver for AutoIt.

License

Notifications You must be signed in to change notification settings

Sven-Seyfert/autoit-webdriver-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to autoit-webdriver-boilerplate【ツ】

license release au3WebDriver autoit last commit contributors Discord


Description | Features | Getting started | Configuration | Contributing | License | Acknowledgements

Description

The project "autoit-webdriver-boilerplate" can be used as quick entry point for the awesome au3WebDriver project by @Danp2 (and @mlipok). The intention is, give people a easy start with WebDriver for AutoIt.

Features

Branches

The different kinds of examples, are (and will be) separated in different branches of the repository. In this overview you basically can see which branch contains which example of WebDriver actions. Some examples and their code could be implemented in a shorter way, but this is made by design and follows a educational purpose.

Branch Description of the
WebDriver actions
Websites in use Browser automation
flow (steps)
Test
Chrome
Test
Firefox
Test
MSEdge
main - open website
- confirm cookie consent dialog
- navigate between pages
- get table texts
- https://www.w3schools.com/ link 🟢 2024-09-14
v128.0.6613.138
🟢 2024-09-14
v130.0.0.2283
🟢 2024-09-14
v128.0.2739.79
fill-form-take-screenshot - open website
- navigate to specific area
- fill a form
- take screenshots
- https://demoqa.com/ link 🟢 2024-09-14
v128.0.6613.138
🟢 2024-09-14
v130.0.0.2283
🟢 2024-09-14
v128.0.2739.79
google-search - open website
- confirm cookie consent dialog
- enter search query
- choose specific match by text
- https://www.google.de/ link 🟢 2024-09-15
v128.0.6613.138
🔴 2024-09-15
v130.0.0.2283
🟢 2024-09-15
v128.0.2739.79
multiple-browser-tabs - open website
- open three more websites in separate browser tabs
- do actions (screenshots) for each tabs
- navigate through tabs, close tabs
- https://github.com/Sven-Seyfert/autoit-webdriver-boilerplate
- https://www.autoitscript.com/wiki/WebDriver#FAQ
- https://autoit.de
- https://pkg.go.dev
link 🟢 2024-09-15
v128.0.6613.138
🟢 2024-09-15
v130.0.0.2283
🟢 2024-09-15
v128.0.2739.79

WebDriver actions function list

In file src/common/webdriver-actions-handler.au3 you can find the following functions which should help you in terms of browser automation actions. These functions are used in the different branches and especially in the _Steps() function and their subfunctions (entry point of the browser automation).

Area Function Purpose
Navigation
_NavigateTo($sUrl) Open the specific URL.
_OpenNewTab() Open new tab and switch to the newly created tab context.
_PreviousTab() Switch to previous (left) tab with context switch.
_NextTab($bShouldClose = False) Switch to next (right) tab with context switch.
_CloseTab() Close current active tab and switch to next (right) tab, with context.
_BrowserBack() Make a browser history back action (backward arrow).
_GetCurrentBrowserTabHandle() (internal) Get the active browser tab handle, to deal with tab navigation.
_GetBrowserTabHandles() (internal) Get handles of all browser tabs, to deal with tab navigation.
_SwitchTab($sHandle) (internal) Switch to tab handle context.
Elements
_ExistsElement($sSelector) Returns the boolean statement about whether an element exists or not.
_FindElement($sSelector) Get element id (UUID) which is necessary to interact with the DOM elements.
_FindElements($sSelector) Get a list of elements (of UUIDs) for further interactions (see "_FindElement").
_ClickElement($sSelector) Click DOM element by selector.
_GetElementText($sSelector) Get the text of the specific DOM element.
_GetElementsTexts($sSelector) Get a list of texts of the specific DOM elements.
_SetElementText($sSelector, $sValue) Set text to a element like an input field.
_WaitForVisible($sSelector) Wait until a element is visible.
Screenshot
_TakeScreenshot() Create a screenshot of the whole browser window and save this screenshot in the output directory.
_TakeElementScreenshot($sSelector) Create a screenshot of a specific area/element and save this screenshot in the output directory.
_CreateScreenshotFile($sResponse) (internal) Write screenshot data to output directory.
iFrames
_EnterIFrame($sSelector) Move context to an iFrame.
_LeaveIFrame() Leave the context of the previous entered iFrame (move out).

Getting started

Preconditions

As assumption, your "browser" of choice which should be automated, have to be installed on your system. Not the "driver" (chromedriver.exe, geckodriver.exe etc.), your browser.

Installation

Fork or clone the repository. Alternatively you can download the latest release package. That should be all.

Usage

Open the project in your editor/IDE and navigate to folder src. Open main.au3, check and adjust the values of function _SetGlobalValues() and start the program. By default, in case you fulfill the preconditions, the driver should start and should execute some simple webdriver actions like described in the features section (for the specific branch).

Adjust the _Steps() function content in website-steps-handler.au3 to your requirements and goals, use the prepared wrapper functions in src\common\webdriver-actions-handler.au3 and in as best case, you also want to follow the POM (page object model) structure like prepared too.

Configuration

Adjust the content/values of function _SetGlobalValues() in src\main.au3.

Func _SetGlobalValues(ByRef $mConfig)
    $mConfig.Driver            = 'firefox' ; chrome|firefox|msedge
    $mConfig.IsHeadlessMode    = False     ; False|True
    $mConfig.IgnoreSSLAndCerts = False     ; False|True
    $mConfig.Delay             = 300       ; delay for supporting a robust waiting behavior (page load, clicks, texts etc.)
    $mConfig.BrowserWidth      = 1600      ; or 1920, etc.
    $mConfig.BrowserHeight     = 900       ; or 1080, etc.
    $mConfig.LocatorStrategy   = Null      ; will be set in function "_SetLocatorStrategy()"
    $mConfig.BrowserMode       = 'size'    ; fullscreen|maximize|size (default is 'size' which applies .BrowserWidth and .BrowserHeight)

    ; This is the default installation path, change this in case it's another on your system.
    $mConfig.FirefoxBinary = 'C:\Program Files\Mozilla Firefox\firefox.exe'

    ; Shutdown webdriver on find element error (default is True).
    $mConfig.TeardownOnFindElementError = True

    ; do not change this
    $bAlreadyTeardown = False
EndFunc

Contributing

To be defined [...]

License

Distributed under the MIT License. See LICENSE for more information.

Acknowledgements

To the top

About

The project "autoit-webdriver-boilerplate" can be used as quick entry point for the awesome "au3WebDriver" project by @Danp2 (and @mlipok). The intention is, give people a easy start with WebDriver for AutoIt.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages