Selenium WebDriver Plugin/en: Unterschied zwischen den Versionen

Aus expecco Wiki (Version 2.x)
Zur Navigation springen Zur Suche springen
(→‎Browser Support: Link to required configuration for InternetExplorerDriver)
(→‎Connection Editor: update description for new expecco version)
Zeile 77: Zeile 77:
[[Datei:SeleniumWebDriverConnectDialog.png]]
[[Datei:SeleniumWebDriverConnectDialog.png]]


#''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.
#''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.
#''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.
#''Save settings to file'': Save all entered settings to a file (*.csf).
#''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.
#''Save settings as attachment'': Save all entered settings as attachment in an open project.
#''Save settings as attachment'': Save all entered settings as attachment in an open project.
#''Save settings as JSON attachment'': Save all entered settings in JSON format as attachment in an open project.
#''Advanced view'': Toggle the view to enter [[#Advanced Settings|advanced settings]].
#''Save settings to file'': Save all entered settings to a file (*.csf).
#''Version info'': Opens a window showing the used versions of the Selenium server, the selected browser and its driver.
#''Version info'': Opens a window showing the used versions of the Selenium server, the selected browser and its driver.
#''Online documentation'': Open this online documentation page.
#''Online documentation'': Open this online documentation page.
#''Connection name'': Enter the name of the connection used to show it in the GUI browser. (Optional)
#''Connection name'': Enter the name of the connection used to show it in the GUI browser. (Optional)
#''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 "<code>file://</code>" scheme, e.g. "<code>file:///C:/Users/admin/Desktop/index.html</code>".
#''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.
#''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.
#''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 "<code>file://</code>" scheme, e.g. "<code>file:///C:/Users/admin/Desktop/index.html</code>".
#''List of advanced settings'': If you have checked the [[#Advanced Settings|advanced settings toggle (5)]], they will be displayed here.
#''Advanced view'': Toggle the view to enter [[#Advanced Settings|advanced settings]].
#''Information on the selected browser'': Here, the selected browser type is shortly characterized.
#''Information on the settings'': It shows which Selenium, browser and driver version will be used regarding the current settings. If you have set [[#Advanced Settings|advanced settings]], they will also be displayed here.


===Advanced Settings===
===Advanced Settings===

Version vom 7. Januar 2019, 16:32 Uhr

Introduction[Bearbeiten]

Use the Selenium WebDriver Plugin to test or automate interactions of applications running in a web-browser. The plugin can be (and usually is) used with the GUI Browser, which helps in the creation of tests. Moreover, the GUI Browser can record UI sessions, which can later be customised or refactored as required.

The Selenium WebDriver Plugin replaces the previous Selenium Web Test Plugin, which was based on the now outdated Selenium RC framework.
The new web driver uses the Selenium WebDriver for automation, and replaces the previous interface. (see https://www.guru99.com/introduction-webdriver-comparison-selenium-rc.html for background information and a description of the differences.)

Browser Support[Bearbeiten]

This plugin supports (among others) the Chrome/Chromium, Edge, Firefox, Internet Explorer and Opera browsers.
Safari under OSX must be at least version 10, and OSX must be at least El Capitan. In addition, many other other browsers, UIs and devices support the webDriver protocol, and can thus be automated/tested with expecco.

Each browser has a driver ("WebDriver") for opening and controlling a browser window. Usually, the driver is a separate program which translates webDriver requests into browser-specific interface calls. However, there are also browsers and programs which have the webDriver protocol already built in.

The expecco installation package includes drivers for common browsers. However, you may have to update a driver, if the browser version changes. The used drivers are located in your expecco installation directory below the installation folder in:

packages/exept/expecco/plugin/seleniumWebDriver/lib

(of course, with "\”s instead of "/"s on Microsoft Windows operating systems). To use a different driver, check the "Advanced" toggle in the connection dialog and add the driver's path to the settings (see below).

In some cases, expecco may show a warning, that the driver version might 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

Bulb.pngPlease verify that the driver's version is compatible with the browser version. If in doubt, consult the version history (eg. for Chrome: https://chromedriver.storage.googleapis.com/2.25/notes.txt).

Bulb.pngNotice: For Internet Explorer, "Protected Mode" settings must be set to the same value for all zones, to be able to start a connection. (in the Internet Explorer, open "Settings" - "Internet Options" - "Security", and set the value of "protected mode" to the same in all 4 zones; otherwise, you'll get error- and warning dialogs when connecting). See also the required configuration to use InternetExplorerDriver.

Bulb.pngAlso notice: the plugin uses JavaScript for some advanced functions, and those functions require that JavaScript is enabled in the browser. This is especially needed to use the GUI browser and the recorder. Executing tests may be possible without JavaScript, if no blocks are used which rely on JavaScript. If you get an error like "org.openqa.selenium.JavascriptException: Error executing JavaScript", make sure that JavaScript is enabled in the browser and that the versions of the browser and the associated driver are compatible.

Quick Start[Bearbeiten]

Open Browser / Connecting[Bearbeiten]

  • Start expecco
  • Click on "New Testsuite"
  • Click on the GUI-Browser symbol (GUIBrowser.png)
  • A new Tab appears, containing the GUI-Browser
  • Click on "Connect" and choose "Selenium Testing". The Connection Dialog appears (see details below)
  • Choose the type of browser (eg. "firefox" and enter the URL of the tested web site (eg. "http://www.myHost.com") and )
  • Click on "Connect"
  • A browser is started automatically, and the page is shown
  • As soon as the connection is established, the page's elements are shown in the GUIBrowser's left tree view

Start a Recording[Bearbeiten]

  • After a connection has been established, click on the record icon (Recording.png) in the GUIBrowser.

Inspecting Elements[Bearbeiten]

  • Select an element in the browser's element-tree, or move the mouse over it in "follow-mouse mode". If your browser does not support this "follow-mouse" mode, try opening a recorder, and move the mouse there.

The element's attributes are shown in the lower-center attribute/property list.

Manually adding Actions and Checks[Bearbeiten]

  • In addition to recording, actions and checks can also be selected from the upper-centre action list. Select one there and either try it immediately or add it to the recording sequence via the add-action button at the top far right.

Connecting[Bearbeiten]

Connection Editor[Bearbeiten]

The connection editor defines, changes or starts a connection. Open the GUI browser, click on "Connect" and select "Selenium Testing (WebDriver)". You can also create attachments or files containing connection parameters ("connection settings") without actually connecting to/opening a new browser connection via the "Save Connection Settings" menu item.

When opened, the connection editor presents a number of fields and load/save buttons in its toolbar menu:


SeleniumWebDriverConnectDialog.png

  1. 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.
  2. 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.
  3. Save settings as attachment: Save all entered settings as attachment in an open project.
  4. Save settings as JSON attachment: Save all entered settings in JSON format as attachment in an open project.
  5. Save settings to file: Save all entered settings to a file (*.csf).
  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 page.
  8. Connection name: Enter the name of the connection used to show it in the GUI browser. (Optional)
  9. 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.
  10. 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".
  11. Advanced view: Toggle the view to enter advanced settings.
  12. Information on the selected browser: Here, the selected browser type is shortly characterized.
  13. Information on the settings: It shows which Selenium, browser and driver version will be used regarding the current settings. If you have set advanced settings, they will also be displayed here.

Advanced Settings[Bearbeiten]

Besides the used browser and the start URL, more settings and possibly "capabilities" may be required. To see click on the "Advanced" toggle. 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.
  • Headless: to open the browser in "headless" mode, i.e. without a window. Not all browsers/drivers support this mode.
  • Binary: Enter the path to the binary of the selected browser. Use this if the browser cannot be found automatically by Selenium, or if you have another browser version installed or to be tested against.
  • Driver: For each browser, a particular driver is needed for automation. New browser versions often also need a new driver version. If you don't want or cannot use the driver provided by expecco, set its path here.
  • Command Line Options: arguments passed to the browser-command. For example the chrome browser supports a "--disable-extensions" command line argument, firefox supports "--safe-mode" and "--profile". These options are browser- and possibly browser-version specific. Most browsers allow for a "--help" argument, which you may try in a shell window to find out.
  • 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 the connection's behavior. To add specific capabilities, set them in this field. Write "<capability name>: <value>" or "<capability name> = <value>", one entry per line.

    The set of capabilities needed or supported are browser- and driver specific. Please refer to the concrete driver's documentation as found via the driver links above. Common capabilities are: "app" or "application", "url", etc. For drivers which communicate with mobile devices, the capabilities also select which device to use and/or wether an emulator should be started.

    You can also set properties for the Firefox browser - for this, use the same syntax as for capabilities, but add a leading $ to the property name.

    Properties used by expecco internally (such as browser type, url or remote host) are prefixed by a "#"-character.

Remote Connections[Bearbeiten]

To start a browser on a remote computer, copy the Selenium server and the required driver to that computer. You find the files in your expecco installation at "packages\exept\expecco\plugin\seleniumWebDriver\lib". Start the Selenium server (on the remote host) with:

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 <nr>" command line argument. 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.

Headless Browsing[Bearbeiten]

"Headless Browsing" means: "without a window", and is useful to test web-pages for reachability, performance and structure. You can either use the HTMLUnit browser type, which simulates a browser, or run against one of the real browser's in headless mode. Notice, that not all browsers support this headless mode - we recommend using "firefox" for this. Also notice, that in order to verify that a web page's interaction with a browser works correctly, you should test against real browsers. For an introduction on what "headless browsing" means, see for example [1]

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" -> "Plugins" -> "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 which support remote recording in the integrated expecco recorder: the behaviour of the recorder is (apart from small differences due to technology-specific limitations) the same across different connections.

Use of this recorder has some advantages over direct recording in the browser:

  • it can be used with remote machines/connections/mobil devices
    especially for mobile devices, which may be all located in a separate (server-) room
  • it provides precise control over which event is to be recorded.
    For example, for clicks, there are alternative ways to record: as "press-release", as "click", as "move-then-click", as "move-then-press-delay-release". Depending on the page's underlying event handling (typically done in JavaScript), either one may be required.

Once connected to a browser, the integrated recorder can be used to record a test case. Start the recorder by selecting the appropriate connection in the GUI browser's left tree 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