حول
Keyword driven automation for the web
أدوات التطويرالنمو المقاس للنجوم
- خلال 24 ساعة
- ٠
- خلال 7 أيام
- جارٍ جمع السجل
- خلال 15 يومًا
- جارٍ جمع السجل
- خلال شهر
- جارٍ جمع السجل
تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.
README.md
الأصل
Keyword based test automation for the web.
Table of Contents
Introduction
QWeb is an open-source library for web testing and automation that can be used with Robot Framework or directly from Python. Its core strength lies in an intuitive, human-readable API that makes automated tests easy to write, understand and maintain.
QWeb follows a text-first approach, encouraging test cases that describe user interactions rather than the underlying implementation of a web application. It also provides attribute-based locators, CSS selectors, XPath and image-based recognition for situations where more precise or specialized element identification is needed.
Prefer the simplest locator that uniquely and reliably identifies the intended element.
Higher abstraction reduces unnecessary dependencies on implementation details. Explicit selectors provide greater precision when those details matter.
QWeb aims to make web automation easy and maintainable through:
- Human-readable syntax: intuitive keywords and simple locator arguments.
- Text-based locators: interact with elements using visible text, labels and nearby text as anchors.
- Attribute-based locators: identify elements by descriptive attribute values without depending on specific attribute names or DOM structures.
- CSS and XPath selectors: precisely identify elements using explicit matching conditions and structural relationships.
- CSS text filters: combine CSS selectors with partial or exact visible text matching.
- Automatic waits: built-in retry logic in most keywords reduces the need for explicit waits.
- Automatic frame handling: search across frames without manual frame switching.
- Automatic alert handling: manage unexpected browser alerts.
- Shadow DOM support: locate and interact with elements inside open shadow roots when enabled.
- Built-in bitmap comparison: identify and verify elements by their visual appearance.
- Python API and extensibility: use QWeb directly from Python or build custom keywords that reuse its search and interaction functionality.
- Technology agnostic: works across a wide range of web technologies and frameworks.
Quick Example
*** Settings ***
Library QWeb
*** Test Cases ***
User Can Log In
OpenBrowser https://example.com chrome
TypeText Email [email protected]
TypeSecret Password ${PASSWORD}
ClickText Sign in
VerifyText Dashboard
Supply ${PASSWORD} externally, for example through a Robot Framework variable.
See more examples, including direct Python usage.
Requirements
Python 3.11-3.14 and Robot Framework 7.0 or above.
Installation
Windows
python -m pip install QWeb
Linux/Mac
Some Linux distributions (Ubuntu) use snap to install browsers, which can cause problems with non-default binary paths, user data directories and profile locations. We suggest installing the browser via terminal, for example:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt-get install -y ./google-chrome-stable_current_amd64.deb
Make sure the following dependencies are installed:
sudo apt-get install python3-tk python3-dev scrot
python3 -m pip install python-xlib
Then install QWeb:
python3 -m pip install -U pip
python3 -m pip install QWeb
The above command also installs supported versions of Selenium and Robot Framework, along with other dependencies.
Automatic browser & driver management
Since Selenium 4.10.0, browser drivers can be automatically downloaded and installed using Selenium Manager, provided that the driver is not found in PATH.
For Chrome, browser_version can also be given; if your locally installed Chrome matches this version,
it will be used. If not, a suitable version of Chrome for Testing will be automatically downloaded.
See examples in the OpenBrowser keyword documentation
Manual driver management
For manual installation of drivers, see the Selenium documentation.
NOTE: Manual driver management should only be used in exceptional cases. Letting Selenium Manager handle drivers is the preferred, less error-prone option.
Usage
Documentation
- QWeb documentation – guides for installation, locators, frames, Shadow DOM and common tasks.
- Locator Strategies – choosing and using text, attribute, CSS, XPath and image-based locators.
- Shadow DOM – working with elements inside shadow roots.
- Keyword Reference – available keywords, arguments and usage examples.
- Copado Robotic Testing documentation
- QWeb tutorial – practical examples and exercises.
Examples
Basic usage
The simplest way to interact with web elements is often by their visible text. Elements such as input fields and dropdowns can also be found by their nearest label.
*** Settings ***
Library QWeb # Import library
*** Test Cases ***
Basic interaction
OpenBrowser https://qentinelqi.github.io/shop chrome # Open Chrome and go to the given URL
VerifyText The animal friendly clothing company # Assert heading text
ClickText Scar the Lion # Click link text
ClickText Add to cart # Click button with specific text
DropDown Size Large # Select value (Large) from dropdown (Size)
Locator strategies
QWeb provides several complementary locator strategies with different levels of abstraction. The locator strategy is typically expressed through the keyword name itself, making the intent of each interaction clear.
| Strategy | Example |
|---|---|
| Visible text | ClickText Save |
| Attribute value | ClickItem save-button |
| CSS selector | ClickElement css\=button#save |
| XPath | ClickElement //button[@id\="save"] |
| Reference image | ClickIcon save.png |
Text and Item locators reduce dependencies on the underlying implementation, while CSS and XPath provide greater control when more precise element identification is needed.
QWeb also supports custom CSS text filters (QWeb extensions, not standard CSS), allowing structural and attribute-based selectors to be combined with visible text matching.
# Partial text matching
ClickElement css\=div.card:has-text("Products")
# Exact text matching
ClickElement css\=button.primary:text-is("Save")
Some keywords, such as TypeText and GetText, support multiple locator strategies for added flexibility.
TypeText Email [email protected]
TypeText css\=input[name\="email"] [email protected]
${price}= GetText Total
${price}= GetText css\=#cart .total
In Robot Framework source, escape equals signs in literal XPath and CSS locators with a backslash (\=).
See the Locator Strategies guide for detailed explanations, supported keywords, Shadow DOM compatibility and usage examples.
Timeouts and anchors
By default, QWeb tries to locate an element for 10 seconds. The default timeout is configurable, and a timeout can also be specified for individual keywords.
When text is not unique, use anchor to pick the instance closest to some nearby text, or index to pick it by position.
ClickText Sign in
ClickText Sign in timeout=30
ClickText Sign in anchor=Email # instance closest to the text "Email"
ClickText Sign in index=3 # third instance
For backward compatibility, a numeric anchor (for example anchor=3) is still treated as an index. New tests should use index instead.
Shadow DOM and visibility
Modern web applications often use Shadow DOM to encapsulate components. Shadow DOM searching is off by default, so searches stay in the light DOM and don't pick up unintended matches from inside components. When you enable it, QWeb automatically searches open shadow roots too, without you having to locate shadow hosts or traverse shadow boundaries yourself.
SetConfig ShadowDOM True # Search both light DOM and open shadow roots
SetConfig ShadowDOM False # Search light DOM only
When Shadow DOM searching is enabled, Text, Item and CSS locators can find elements inside open shadow roots, and so can the input keywords listed in the Locator Strategies guide.
ClickText Save
ClickItem save-button
ClickElement css\=button#save
CSS locators find elements inside open shadow roots, including nested ones. However, the whole selector must match inside a single shadow root (or the light DOM). You cannot write a selector that starts outside a shadow root and continues inside it, and shadow-piercing syntax such as >> or >>> is not supported.
ClickElement css\=.actions button # Works: .actions and button are in the same shadow root
ClickElement css\=settings-panel .actions button # Fails: settings-panel is the shadow host, .actions is inside its shadow root
XPath cannot find elements inside shadow roots.
QWeb searches for visible elements by default. Visibility-related search behavior can be configured using SetConfig and the following settings:
VisibilityOffsetcheckInViewport
Example:
*** Settings ***
Library QWeb
*** Test Cases ***
Click Shadow DOM Element
SetConfig ShadowDOM True
OpenBrowser chrome://settings/content/popups chrome
ClickText Sites can send pop-ups
See the Shadow DOM guide and keyword documentation for more information.
Working with tables
QWeb includes keywords for easy interaction with table data.
Consider the following table as an example:

UseTable Firstname
${row}= GetTableRow //last # returns 5
${row}= GetTableRow //last skip_header=True # returns 4
...
${row}= GetTableRow Jim # returns 4
${row}= GetTableRow Jim skip_header=True # returns 3
${cell_value}= GetCellText r1c2 # Returns "John", first name is column 2.
${cell_value}= GetCellText r-1/c2 # Returns "Tina", -1 points to last row
${cell_value}= GetCellText r-2/c2 # Returns "Jim", -2 points to second last row
Changing configuration
QWeb's behavior can be changed with the SetConfig keyword.
SetConfig SearchMode Draw # Highlight all found elements with blue rectangle
SetConfig DefaultTimeout 60s # change default/automatic timeout for all keywords
VerifyText User account created # Retries for up to 60 seconds, then fails if the text is not visible
Running with Python
QWeb can be used directly from Python without running Robot Framework test cases. Its Python API provides the same high-level automation approach and can be integrated into Python scripts, applications and other test frameworks.
from QWeb import QWeb
qweb = QWeb()
qweb.open_browser("about:blank", "chrome")
qweb.go_to("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select")
title = qweb.get_title()
# returns 'W3Schools Tryit Editor'
qweb.verify_text("The select element")
qweb.drop_down("Choose a car", "Saab")
qweb.click_text("Submit")
qweb.verify_text("Your input was received as:")
qweb.verify_text("cars=saab")
CSS selectors can also be used directly from Python. Robot Framework's equals-sign escaping is not needed in Python strings:
qweb.click_element('css=button.primary:text-is("Save")')
Extending QWeb with custom keywords
QWeb can also serve as a foundation for application-specific automation libraries. Custom Python keywords can combine existing QWeb operations or reuse its element search functions to implement specialized interactions without duplicating the underlying search logic.
For example, a custom Robot Framework library can compose QWeb operations into a reusable business-level keyword:
# CustomKeywords.py
from robot.libraries.BuiltIn import BuiltIn
class CustomKeywords:
@property
def qweb(self):
# Reuse the QWeb instance imported by the test suite
return BuiltIn().get_library_instance("QWeb")
def save_changes(self):
self.qweb.click_text("Save")
self.qweb.verify_text("Changes saved")
*** Settings ***
Library QWeb
Library CustomKeywords.py
*** Test Cases ***
Save Settings
OpenBrowser https://example.com/settings chrome
Save Changes
When using internal modules rather than the public QWeb API, check compatibility with the QWeb version in use.
More examples in the QWeb tutorial.
Changelog
See RELEASE.md
Contribute
Found a bug? Want to propose a new feature or improve documentation? Please start by checking our contribution guide
Community
Want to join the community on Slack? On the official Robot Framework workspace, there is a QWeb channel where you can discuss keywords, issues and improvements with others. Join Now
License
Apache 2.0 License. See LICENSE.
Resources
استكشف مشاريع مشابهة ومرتبطة
جارٍ التحميل…