Selenium WebDriver Plugin/en: Unterschied zwischen den Versionen

Aus expecco Wiki (Version 2.x)
Zur Navigation springen Zur Suche springen
Zeile 67: Zeile 67:


==Connection Blocks==
==Connection Blocks==
SeleniumWebDriverLibrary offers a number of blocks to start a Selenium connection within a testrun. The ''connection name'' identifies the connection during the run, if the test switches between different connections. To start a connection with predefined settings, save them in the connection dialog (as attachment), and use the ''Connect From File'' action block.
SeleniumWebDriverLibrary offers a number of blocks to start a Selenium connection within a testrun. The ''connection name'' identifies the connection during the run, if the test uses multiple connections and switches between them (eg. if multiple browser windows are open simultaneously). To start a connection with predefined settings, save them in the connection dialog (as attachment), and use the ''Connect From File'' action block.


=Plugin Settings=
=Plugin Settings=

Version vom 21. Juni 2018, 09:05 Uhr

Introduction[Bearbeiten]

You can use the Selenium WebDriver Plugin to create webtests. The plugin can be (and usually is) used with the GUI Browser, which supports the creation of tests. Moreover, it allows the recording of test runs.

The Selenium WebDriver Plugin replaces the previous Selenium Web Test Plugin, which was based on the now outdated Selenium RC interface.
The new web driver uses the Selenium WebDriver for automation, and replaces the previous interface.

Browser Support[Bearbeiten]

This plugin supports (among others) the Chrome/Chromium, Edge, Firefox and Internet Explorer browsers. Each browser has a driver for opening and controlling a browser window. They possibly have to be updated if the browser version changes. The used drivers are located in your expecco installion directory below the installation folder in:

packages/exept/expecco/plugin/seleniumWebDriver/lib

In some cases, expecco may show a warning, that the driver version could be incompatible with the browser. This does not mean per se, that the combination does not work; instead, it means that the combination has not been tested by eXept, but may nevertheless work. If such a warning is shown, check the "Do not show this warning again" toggle, to have expecco remember that combination as "trusted" in your settings.

You find new driver versions at the following addresses:

Chrome/Chromium ChromeDriver
Edge Microsoft WebDriver
Firefox GeckoDriver
Internet Explorer IEDriverServer
Opera Opera driver

Notice: For Internet Explorer, "Protected Mode" settings must be set to the same value for all zones, to be able to start a connection.

The plugin uses JavaScript. If you get an error like "org.openqa.selenium.JavascriptException: Error executing JavaScript", make sure that the browser allows the execution of JavaScript and that the versions of the browser and the associated driver are compatible.

Connecting[Bearbeiten]

Connection Edtitor[Bearbeiten]

The connection editor assists you in defining, changing or starting a connection. Open the GUI browser, click on Connect and select Selenium Testing (WebDriver).

SeleniumWebDriverConnectDialog.png

  1. Load settings from file: Open a saved settings file (*.csf). Its settings will be added to the editor. Already entered inputs that are not conflicting will remain unchanged.
  2. Load settings from attachment: Open an attachment containing connection settings from an open project. This settings will be added to the editor. Already entered inputs that are not conflicting will remain unchanged.
  3. Save settings to file: Save all entered settings to a file (*.csf).
  4. Save settings as attachment: Save all entered settings as attachment in an open project.
  5. Advanced view: Toggle the view to enter advanced settings.
  6. Version info: Opens a window showing the used versions of the Selenium server, the selected browser and its driver.
  7. Online documentation: Open this online documentation.
  8. Connection name: Enter the name of the connection used to show it in the GUI browser. (Optional)
  9. URL: Enter the URL to open at startup. To open an empty browser window, leave this field empty. To open a local file use the "file://" scheme, e.g. "file:///C:/Users/admin/Desktop/index.html".
  10. Browser type: Choose the type of browser to use. Ensure it is installed and the version of the used driver is compatible with the browser version.
  11. List of advanced settings: If you have set advanced settings, they will be displayed here.

Advanced Settings[Bearbeiten]

Besides the used browser and the start URL, more settings are possibly required. To set them, change the view in the connection menu using the appropriate menu entry. Depending on the selected browser type you get different entry fields.

  • Remote Server: To open a browser on a remote host, start a Selenium server there and set this field to its address. You can also enter a local address if you do not want the Selenium server to start automatically or if it is already running. See the next section Remote Connections on how to start a Selenium server.
  • Binary: Enter the path to the binary of the selected browser, if it cannot be found automatically by Selenium or you have another version installed.
  • Driver: For each browser, a particular driver is needed for automation. New browser versions often also need a new version of the associated driver. If you don't want or cannot to use the driver provided by expecco, set its path here.
  • Firefox Profile: For Firefox, it is possible to set a Firefox Profile, containing specific settings. If no profile is set, each connection will use a new empty one.
  • Capabilities: Selenium connections can use several capabilities to define connection behaviors. If you want to use capabilities, you can set them in this field. Write <capability name>: <value> or <capability name> = <value>; one entry each line. You can also set properties for Firefox browser. Therefore use the same syntax as for the capabilities, but add a leading $ to the property name.

Remote Connections[Bearbeiten]

To start a browser on a remote computer, you have to copy the Selenium server and the required driver to that computer first. You find the files in your expecco installation at "packages\exept\expecco\plugin\seleniumWebDriver\lib. Start the Selenium server using

java -jar selenium-server-standalone-3.6.0.jar

By default, the server will listen on port 4444. To use another port, set it with the "-port #" flag. To connect to that server, set the "remote server" parameter of the connection to "<Server-Address>:4444/wd/hub".

Check and possibly configure your firewall to allow transmission through the port.

Connection Blocks[Bearbeiten]

SeleniumWebDriverLibrary offers a number of blocks to start a Selenium connection within a testrun. The connection name identifies the connection during the run, if the test uses multiple connections and switches between them (eg. if multiple browser windows are open simultaneously). To start a connection with predefined settings, save them in the connection dialog (as attachment), and use the Connect From File action block.

Plugin Settings[Bearbeiten]

To use certain browser installations or drivers (as default, for every connection), set them in the settings dialog of the plugin (Extras > Settings and in the Plugins section Selenium WebDriver Extension). The settings there are used as default, unless overwritten by an individual connection configuration.

Recorder[Bearbeiten]

The following description applies to all GUI technologies: the behaviour of the recorder is the same across different connections.

Once connected to a browser, the integrated recorder can be used to record a test case. Start the recorder by selecting the appropriate selection in the GUI browser and click the record button. The recorder opens a new window. Each click in the window records an action. More actions are available in the menu. Recorded actions are added to the workspace of the GUI browser to form a sequence of interactions. This sequence can be edited, parametrized or replayed immediately. When finished, it should be saved into the suite as a new "Test Action".

SeleniumWebDriverRecorder.png

Components of the recorder window

  1. Pause recording: If the control lamp is red, the recorder is in "recording"-mode. Pause the recording by clicking on this lamp. The lamp will turn to grey. In this state you can execute actions with the recorder, but they are not recorded. Click again to resume the recording.
  2. Update: Update the screenshot on the element tree. Necessary if the recorder view does not fit the browser content.
  3. Follow-Mouse: The element under the cursor is selected in the GUI browser.
  4. Element Highlighting: The element under the cursor gets a red frame.
  5. Element Tools: Select which tool to use for recording. The selected action is triggered by each click in the view. Following actions are available:
    • Auto: Combination of all other tools. A Click is recorded for every left click and Drag And Drop for moving the mouse between press and release of the mouse button. All other actions are available by right clicking on an element.
    • Click: Single click on the element
    • Set Text: Set the text of an entry field
    • Clear Text: Clear the text from an entry field
    • Check Text: Check if the element contains a certain text
    • Check Attribute: Check whether the value of a certain attribute matches the specified value
    • Drag And Drop: Drag and drop an element to another supporting this function
    • Switch to Frame: Switch to the context of the selected frame, making its content available.
    • Select: Diefferent select actions e.g. to use in select menus
    • Wait for: Different actions to wait for certain events refering to the selected element
  6. Browser Tools: Actions not refering to ocertain elements. Following actions are available:
    • Get: Get a URL
    • Scroll: Scroll the content of the browser window
    • Check Title: Check if the title of the current page matches the specified value
    • Switch To Parent: Return from a frame context to its parent context
    • Switch To Window...: Switch between different windows or tabs of a connection
    • Wait for: Different actions to wait for certain events not refering to an element
  7. Page navigation: Actions for page navigation: Back, Forward and Refresh Page
  8. Alert Handling: Click this button if the browser shows an alert, to be able to select the actions for alert handling.
  9. Online Documentation: Open this online documentation.
  10. Resize Window to Screen Size: Change the size of the window to show the whole screenshot.
  11. Set Screen Scale to Fit Window: Scale the screenshot to fully fit in the window
  12. Scale: Changes the scale of the screenshot. Can also be adjusted by the slider on the right.
  13. Control Lamp: Shows the state of the recorder
    green: The recorder is ready
    red: The recorder is blocked, the view and the element list are updated
    grey: The recorder lost the connection (protocol error or closed)

Transferring Old Selenium Tests[Bearbeiten]

This Plugin replaces the previous Selenium Web Test Plugin, which is based on Selenium RC. Selenium RC is no longer supported by their authors and it will also no longer be maintained by exept. The successor is Selenium WebDriver, also referred to as Selenium 2.

Recording of test actions using Selenim IDE is also outdated, as the plugin is not supported by newer browsers. The Selenium WebDriver Plugin uses its own Recorder instead.

Tests which were created with the old Selenium WebTest Plugin using SeleniumLibrary can be executed with the new Selenium WebDriver. For this, go to the plugin settings of Webtest Legacy (Selenium) and check Use WebDriver for execution. Please verify that your tests are still running after this change, as there is no 100% backward compatibility (which is outside the scope of expecco). However, most of the old test actions should run without problems.



Copyright © 2014-2024 eXept Software AG