WebDriver: Difference between revisions
mNo edit summary |
m (→Installation) |
||
Line 55: | Line 55: | ||
** geckodriver.exe for Firefox | ** geckodriver.exe for Firefox | ||
** msedgedriver.exe for Edge (Chromium) or MicrosoftWebDriver.exe for Edge (EdgeHTML) | ** msedgedriver.exe for Edge (Chromium) or MicrosoftWebDriver.exe for Edge (EdgeHTML) | ||
* Run the installation test script (WD_Demo.au3) to validate the installation.<br>The result (for Firefox) displayed in the DOS window should | * Run the installation test script (WD_Demo.au3) and select "DemoNavigation" to validate the installation.<br>The result (for Firefox) displayed in the DOS window should be similar to the following: | ||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
1577552970329 geckodriver DEBUG Listening on 127.0.0.1:4444 | 1577552970329 geckodriver DEBUG Listening on 127.0.0.1:4444 |
Revision as of 22:01, 30 December 2019
This page is still a work in progress.
The W3C WebDriver API is a platform and language-neutral interface and wire protocol allowing programs or scripts to control the behavior of a web browser.
Introduction
WebDriver API
WebDriver enables developers to create automated tests that simulate user interaction. This is different from JavaScript unit tests because WebDriver has access to functionality and information that JavaScript running in the browser doesn't, and it can more accurately simulate user events or OS-level events. WebDriver can also manage testing across multiple windows, tabs and webpages in a single test session.
WebDriver UDF
The WebDriver UDF allows to interact with any browser that supports the W3C WebDriver specifications. Supporting multiple browsers via the same code base is now possible with just a few configuration settings.
Requirements
(Last modified: 2019/12/29)
The following UDFs need to be installed - independent of the Browser you try to automate:
- JSON UDF
- WinHTTP UDF
- WebDriver UDF from github
One of the following Drivers needs to be installed - depending on the Browser type and version you try to automate:
Browser | Download Link | Latest Version / Date | Comments |
---|---|---|---|
Chrome | 80.0.3987.16 / 2019.12.19 | Follow this link to select the correct version depending on the Chrome version you run! | |
Edge | Microsoft | 81.0.370.0 | |
FireFox | github | 0.26 / 2019.10.12 | Firefox version ≥ 60 is recommended Note: You must still have the Microsoft Visual Studio redistributable runtime installed on your system for the binary to run. This is a known bug in version 0.26 which the authors weren't able fix for this release. |
Internet Explorer | Microsoft | ||
Opera | github | 78.0.3904.87 - 2019.11.14 | The versioning of OperaDriver matches the Chromium version on which Opera browser is based on. |
Limitations
Not all WebDriver functions have been implemented by each browser. To check the status goto Danp2's website on Github and scroll down to "Requirements".
Big Picture
How the browser independant and browser dependant parts fit together:
Installation
(Last modified: 2019/12/30)
The following steps are needed to install everything you need to automate your browser:
- Download the files listed in section "Requirements"
- Move the UDFs to a directory where SciTE and Autoit can find them:
- Json.au3 and BinaryCall.au3 from the JSON UDF
- wd_Core.au3 and wd_helper.au3 from the WebDriver UDF
- WinHttp.au3 and WinHttpConstants.au3 from the WinHttp UDF
- Move the browser dependant WebDriver to the same directory:
- chromedriver.exe for Chrome
- geckodriver.exe for Firefox
- msedgedriver.exe for Edge (Chromium) or MicrosoftWebDriver.exe for Edge (EdgeHTML)
- Run the installation test script (WD_Demo.au3) and select "DemoNavigation" to validate the installation.
The result (for Firefox) displayed in the DOS window should be similar to the following:
1577552970329 geckodriver DEBUG Listening on 127.0.0.1:4444
1577552970703 webdriver::server DEBUG -> POST /session {"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}
1577552970704 webdriver::command WARN You are using deprecated legacy session negotiation patterns (desiredCapabilities/requiredCapabilities), see https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities#Legacy
1577552970763 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\xy\\AppData\\Local\\Temp\\rust_mozprofileFvQ4K8"
1577552971027 geckodriver::marionette DEBUG Waiting 60s to connect to browser on 127.0.0.1:62360
...
Debugging
Debug the WebDriver setup
FireFox
(Last modified: 2019/12/28)
Problem | Solution | Reference |
---|---|---|
The installation testing script does not start up FireFox and does not display the DOS window for geckodriver. When you manually run the geckodriver in a DOS window you get message "geckodriver: error: An invalid argument was supplied. (os error 10022)" |
Run the gecko driver from a local HDD. | Stackoverflow |
Debug your Script
FAQ
(Last modified: 2019/12/30)
Connect to a running browser instance
Q: How can I connect to a running browser instance?
A: That's described (for Firefox, but should work similar for other browsers) in this post.
References
(Last modified: 2019/12/28)
Further information sources:
- W3C: https://www.w3.org/TR/webdriver/
- Danp2's thread in the Example Scripts forum: https://www.autoitscript.com/forum/topic/191990-webdriver-udf-w3c-compliant-version-12242019
- Danp2's thread in the General Help and Support forum: https://www.autoitscript.com/forum/topic/192730-webdriver-udf-help-support/