メインコンテンツまでスキップ
バージョン:23.5

Selenium WebDriver Testing with Eggplant Functional

Eggplant Functional supports object-based automated testing of web applications via Eggplant Functional's WebDriver interface. You can use Eggplant Functional to perform pure WebDriver testing or you can combine WebDriver testing with imaged-based testing (using VNC or RDP connections) to achieve a hybrid approach.

Within Eggplant Functional, you have two options to utilize WebDriver. The appropriate option depends on the hosting model of the browsers that you are using for test: you can either self-host the browsers within your own IT infrastructure or you can utilize Sauce Labs' browser-as-a-service platform.

If you will be using self-hosted browsers, you will need to follow the instructions in this section to set up Selenium's WebDriver software and then use Eggplant Functional's WebDriver connection to communicate with your browser.

If you are planning to utilize Sauce Labs as your browser platform, you'll need to connect to the browsers using Eggplant Functional's Sauce Labs connection. The Sauce Labs connection is a hybrid connection which logically presents both a VNC and a WebDriver connection as a single connection within Eggplant Functional. Once you create a Sauce Labs connection, you can send it WebDriver commands using the same syntax you would use if you had created an explicit WebDriver connection. For Sauce Labs connections, you do not need to install the Selenium software and you can ignore the instructions below for configuring Selenium.

ノート

Please see Adding or Editing a SUT in the Connection List for more details on how to create WebDriver and Sauce Labs connections in Eggplant Functional.

Once you have your connection (be it a WebDriver connection or a SauceLabs connection), you can use SenseTalk WebDriver commands and functions to create your tests:

Configuring Selenium on Windows

ノート

The instructions described here are not required if you only plan to access your browsers via Sauce Labs. See the overview at the top of this section for details.

To configure Eggplant Functional to work with the Selenium framework on Windows, you must install the Selenium Grid Server, Java (JDK or JRE), and the appropriate WebDriver for any browser you want to test against.

Configuring Your System

To manually configure Eggplant Functional to work with Selenium on Windows, complete the following steps:

  1. Download the version of the browser you want to test, or verify the version of the browser if it's already installed.

  2. Make sure you have a Java version installed (JDK or JRE) that's compatible with your Selenium Grid Server with standalone option and browser.

  3. Create a folder anywhere on the root of your C: drive.

  4. Download the latest stable version of Selenium Grid (Selenium Grid Server) on the SUT and place it in the new folder.

  5. Create a *.bat file, name it something like "RunSeleniumServer.bat", and add the following information:

      @echo off
    set JAVA_HOME=C:\Program Files\Java\jdk-*****\bin
    "%JAVA_HOME%\java" -jar selenium-server-^^^^^^.jar standalone

    where ***** is the version of the JDK running and ^^^^^^ is the version of the Selenium Grid Server that you have installed. The standalone at the end indicates the standalone option for the Selenium Grid server.

  6. Download the appropriate WebDriver for the browser you want to test to that folder.

  7. Verify your Selenium configuration by executing the *.bat file and verifying that the Selenium server starts as expected.

  8. Verify that you can establish a WebDriver connection to the Selenium environment using Eggplant Functional.

Starting and Stopping the Selenium Grid Server

To start the Selenium Grid Server (if it's not already runnning):

  1. Open a command prompt.
  2. Navigate to the .bat file that you created in the previous section.
  3. Run the .bat file.

To stop the Selenium server, type ctrl + c simultaneously.

Configuring Selenium on Mac

ノート

The instructions described here are not required if you only plan to access your browsers via Sauce Labs. See the overview at the top of this section for details.

To configure Eggplant Functional to work with the Selenium framework on a Mac, you must install the Selenium server, the Java SE Development Kit (JDK), and the appropriate WebDriver for any browser you want to test against.

The following examples use ChromeDriver, the WebDriver for the Google Chrome browser.

Install the Selenium Server and the Oracle JDK

  1.  Install the Homebrew iOS package installer:

    1. Open Terminal and navigate to usr/bin/.
    2. Run the following command:
      ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. Usually the JDK is already installed on a Mac. If necessary, download and install the JDK from Oracle.

    先端

    To install Java using Homebrew, run the following command:

      brew cask install java
  3. From a command prompt, run the following command to install the Selenium server:

      brew install selenium-server-standalone
  4. From a command prompt, run the following command to verify that the Selenium server is installed correctly.

      selenium-server --version

The command should return the Selenium server version that you just installed.

Starting and Stopping the Selenium Server

From a command prompt, run the following command to start the Selenium server:

  selenium-server -port 4444
ノート

Run this command any time you need to start the Selenium server.

ノート

The Terminal window must remain open for the Selenium server to be active and for WebDriver functionality to be available through SenseTalk.

To stop the Selenium server, close the terminal that you used to start the Selenium server.

Install ChromeDriver

For compatibility with Eggplant Functional, you must use Chrome version 60 or later and ChromeDriver version 2.33 or later. Download the WebDriver for Chrome, then complete the following steps to let the Selenium server know the location of ChromeDriver:

  1. Open a command window.

  2. Run the following command:

      sudo nano /etc/paths
  3. Provide your password.

  4. Navigate to the bottom of the file and enter the path to ChromeDriver. For example, your path might look like the following:

      /Users/<username>/Documents
  5. Type Ctrl+X to quit the editor.

  6. Enter Y to save your changes.

  7. Press Enter to confirm your changes.

Enable Automation in Safari

To enable automation in the Safari browser, follow these steps:

  1. Go to Safari > Preferences and select the Advanced tab.
  2. Select Show Develop menu in menu bar. Close Preferences.
  3. Go to Develop > Allow Remote Automation.
ノート

WebDriver automation with Safari requires macOS Sierra (10.12) or later and Safari 10.0 or later.