Anthony  Dach

Anthony Dach

1647135120

Selenium Grid Extras: Helps Set Up & Manage Your Local Selenium Grid

Selenium-Grid-Extras

Selenium Grid Extras is a project that helps you set up and manage your local Selenium Grid. Typical instances of the Grid consists of the HUB and Nodes. The HUB is responsible for managing test sessions and assigning new session idle nodes.

Setup of Grid Extras is made to be simple, just run the packaged JAR file and point the node at the HUB location, Grid Extras will take care of the rest for you. Here are the features you get by using Selenium Grid Extras vs Selenium Grid alone:

  • Ability to control individual grid nodes, following is an incomplete list of OS level tasks:
    • Killing any browser instance by name
    • Stopping any Process by PID
    • Moving mouse to specific location
    • Get Memory usage and disk statistics
  • Automatically upgrade WebDriver binaries
  • Restart node after a set number of test executions
  • Central storage of configurations for all nodes on the HUB server
  • Screenshots at the OS level
  • And much more.

Running

  1. On the initial execution, follow the "Setup Instructions" section.
  2. As part of the initial execution, a starter script start_grid_extras.sh or start_grid_extras.bat will be generated.
  3. After the initial execution, use the generated start script to start HUB or nodes thereafter.
    • This will help with automatic upgrades and downgrades
    • Be careul of putting the Selenium Grid Extras jar file in a directory with spaces. Doing so may cause issues. PR welcome to fix this.

Setup Instructions

Setup is simple, just download the Grid Extras Jar to get started from here: Download Latest

Setting up Grid Hub

  1. In the terminal run following command:
java -jar Selenium-Grid-Extras-Jar.jar

2.   You will be prompted with several questions, first one will ask you if you want to set this computer as a HUB, Node, or both. Answer 2 for HUB

3.   Leave the Host name for Grid Hub as default 127.0.0.1

4.   Set port to be used by Selenium Grid Hub, default is 4444

5.   You will be asked if you wish to auto update Selenium. If you answer yes, then every time Selenium Grid Extras is started it will check fo the latest version of Selenium Stand Alone Server, IEDriver, and ChromeDriver. If you choose to not auto update, you will be asked what versions of each driver to lock into.

Setting up Grid Node

  1. In the terminal run following command:
java -jar Selenium-Grid-Extras-Jar.jar

2.   You will be asked if you wish to use this computer as HUB or Node, select 1 for Node

3.   You will be asked for the host name of the HUB computer, type in the IP or hostname of the HUB computer

4.   When prompted for the port used by the HUB, enter that value

5.   Selenium Grid Extras will attempt to guess the Operating System of the current computer, if it's wrong please enter the correct value

6.   You will be asked what Browsers this Node will host, choose the ones that apply

7.   You will be asked how often to restart your whole computer. By default after 10 tests Selenium Grid Extras will attempt to restart the Node, provided the node is idle. Choose 0 if you do not wish to have the computer automatically restart.

8.   You will be asked if Selenium Grid Extras should automatically check for updates of IEDriver, ChromeDriver and Selenium Stand Alone Server. If you answer no, you will be asked what version to lock into.

9.   Finally, you will be asked if you wish to store all of the Node configs on the HUB. If you answer yes, Selenium Grid Extras will attempt to push Node's configs to the HUB. If it is successful, Selenium Grid Extras will attempt to download all of the configs from the HUB before it starts. This way all of the Node configs can be controlled directly from the HUB.

Changing the logging on the grid hub, nodes, or selenium-grid-extras

  1. For grid extras, create a log4j.properties in the same directory as your jar file. Start the service like : java -Dlog4j.debug -Dlog4j.configuration=file:log4j.properties -cp .:SeleniumGridExtras-1.10.0-SNAPSHOT-jar-with-dependencies.jar com.groupon.seleniumgridextras.SeleniumGridExtras (Use a semi-colon in the classpath for Windows. Use a colon in the classpath for Mac/Linux).
  2. For hub and node log files, add the following to the selenium_grid_extras_config.json file (see selenium_grid_extras_config.json.example for an example):
    "grid_jvm_options": {
    "selenium.LOGGER.level": "WARNING"
    },
     

Upgrading Grid Extras

There are 2 options available for un-attended upgrades

  1. Automatic upgrades can be achieved by selected "auto update" on the first run, or setting "grid_extras_auto_update" key to have value of "1" in selenium_grid_extras_config.json
  2. Manual upgrade trigger can be achieved by making an HTTP GET request against http://node_name:3000/upgrade_grid_extras?version=X.X.X

Auto Restarting Nodes

Starting with release 1.3.0 the nodes have an option of automatically restarting after a certain amount of builds have been executed and the node is currently not busy. This helps to keep the nodes in pristine state for longer periods of time, and clears up and browser crashes, which may have occurred. Some setup will be needed to make this feature work as intended.

  1. Setup default login user
  2. Setup default start up task
  3. Give permission to access OS.
shutdown -r -t 1 -f

Windows

  1. Follow Microsoft's Technical Help
  2. Add start up batch script to StartUp directory or set up a Scheduled Task to start the batch file automatically
  3. No need to setup permission as long as current user can run the following command in the Terminal

OS X

  1. Turn on Automatic Login option and make the desired user auto login
  2. Set up the shell script which starts Grid Extras to run automatically.
  3. Modify the /etc/sudoers to contain this line, where the $USER is the current user that will be used for running grid node.
$USER ALL=(ALL) NOPASSWD: /sbin/shutdown

Linux

  1. ...
  2. Set up the shell script which starts Grid Extras to run automatically.
  3. Modify the /etc/sudoers to contain this line, where the $USER is the current user that will be used for running grid node.
$USER ALL=(ALL) NOPASSWD: /sbin/shutdown

Starting Services

Note: Make sure to run Grid Extras at least once prior to setting it up as a service, so it can ask you the first run questions.

Windows

There are two major ways to make windows automatically start the Grid Extras binary

  • Insert a batch file into StartUp directory
  • Using the Task Scheduler to add the java start command, where the executable will be the path to java.exe and the path to Grid Extras passed in as an argument

Linux

There are a lot of security issues with setting up a cron job as a “build user” and letting that user run in the normal display desktop (DISPLAY=:0 aka the one you see when it is connected to the computer monitor). There is a work around to allow the service to run in DISPLAY=:0 but that’s not recommended.

Instead, it is a much better practice to set up a XVNC server on a Linux computer, with a light desktop manager (FluxBox seems to be a good lightweight choice http://fluxbox.org/). Once VNC server and desktop managers are installed, run the following command to start a virtual DISPLAY:

vncserver :1 -geometry 1024x768

This will start an XVNC server on DISPLAY=:1 with screen resolution of 1024x768. You can tweak these parameters as needed. Note: You might need to add a cron job to restart vncserver in similar fashion, since vncserver will not automatically start after reboot

After you have the virtual display running, add run this command to edit the cron list for current user (vi is the editor used)

crontab -e

Add following lines to the cron list:

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
*/5 * * * * bash -i -c 'cd WORKING_DIRECTORY; export DISPLAY=:1 java -jar SELENIUM_GRID_EXTRAS.jar' >> WORKING_DIRECTORY/log/log.out 2>&1

Where the WORKING_DIRECTORY needs to be replaced with the location where grid extras jar was downloaded, and SELENIUM_GRID_EXTRAS represents the name given to the grid extras jar. This cron will run every 5 minutes.

OS X

Download the SeleniumGridExtras.plist to your computer, open it in editor of choice.

Update the XML file replacing WORKING_DIRECTORY with the location of the selenium grid extras working directory Update the XML file replacing SELENIUM_GRID_EXTRAS.jar with the name Selenium Grid Extras was saved as

Move the com.groupon.SeleniumGridExtras.plist to ~/Library/LaunchAgents/

run

launchctl load ~/Library/LaunchAgents/com.groupon.SeleniumGridExtras.plist

Debugging most common Selenium Grid Test failures

Docker Images

https://github.com/viltgroup/docker-selenium-grid-extras provided by @mariolameiras . If you see any issues with these images please report them on the https://github.com/viltgroup/docker-selenium-grid-extras repo, and not this repo. These are new images, so please keep that in mind.

Contributing

For This project, add functionality, make sure all tests pass, send pull request.

Note: This product exposes your machine to the whole network, anyone on the network will be able to perform OS level task by simply hitting an HTTP url. There are no security measures at the moment, and at the moment no plans to add any security. You have been warned!

Link Backs

This project uses jWMI.java which was taken from www.henryranch.net

Download Details:
Author: groupon
Source Code: https://github.com/groupon/Selenium-Grid-Extras
License: BSD-3-Clause License

#selenium #ruby #java 

What is GEEK

Buddha Community

Selenium Grid Extras: Helps Set Up & Manage Your Local Selenium Grid
Hermann  Frami

Hermann Frami

1651383480

A Simple Wrapper Around Amplify AppSync Simulator

This serverless plugin is a wrapper for amplify-appsync-simulator made for testing AppSync APIs built with serverless-appsync-plugin.

Install

npm install serverless-appsync-simulator
# or
yarn add serverless-appsync-simulator

Usage

This plugin relies on your serverless yml file and on the serverless-offline plugin.

plugins:
  - serverless-dynamodb-local # only if you need dynamodb resolvers and you don't have an external dynamodb
  - serverless-appsync-simulator
  - serverless-offline

Note: Order is important serverless-appsync-simulator must go before serverless-offline

To start the simulator, run the following command:

sls offline start

You should see in the logs something like:

...
Serverless: AppSync endpoint: http://localhost:20002/graphql
Serverless: GraphiQl: http://localhost:20002
...

Configuration

Put options under custom.appsync-simulator in your serverless.yml file

| option | default | description | | ------------------------ | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | | apiKey | 0123456789 | When using API_KEY as authentication type, the key to authenticate to the endpoint. | | port | 20002 | AppSync operations port; if using multiple APIs, the value of this option will be used as a starting point, and each other API will have a port of lastPort + 10 (e.g. 20002, 20012, 20022, etc.) | | wsPort | 20003 | AppSync subscriptions port; if using multiple APIs, the value of this option will be used as a starting point, and each other API will have a port of lastPort + 10 (e.g. 20003, 20013, 20023, etc.) | | location | . (base directory) | Location of the lambda functions handlers. | | refMap | {} | A mapping of resource resolutions for the Ref function | | getAttMap | {} | A mapping of resource resolutions for the GetAtt function | | importValueMap | {} | A mapping of resource resolutions for the ImportValue function | | functions | {} | A mapping of external functions for providing invoke url for external fucntions | | dynamoDb.endpoint | http://localhost:8000 | Dynamodb endpoint. Specify it if you're not using serverless-dynamodb-local. Otherwise, port is taken from dynamodb-local conf | | dynamoDb.region | localhost | Dynamodb region. Specify it if you're connecting to a remote Dynamodb intance. | | dynamoDb.accessKeyId | DEFAULT_ACCESS_KEY | AWS Access Key ID to access DynamoDB | | dynamoDb.secretAccessKey | DEFAULT_SECRET | AWS Secret Key to access DynamoDB | | dynamoDb.sessionToken | DEFAULT_ACCESS_TOKEEN | AWS Session Token to access DynamoDB, only if you have temporary security credentials configured on AWS | | dynamoDb.* | | You can add every configuration accepted by DynamoDB SDK | | rds.dbName | | Name of the database | | rds.dbHost | | Database host | | rds.dbDialect | | Database dialect. Possible values (mysql | postgres) | | rds.dbUsername | | Database username | | rds.dbPassword | | Database password | | rds.dbPort | | Database port | | watch | - *.graphql
- *.vtl | Array of glob patterns to watch for hot-reloading. |

Example:

custom:
  appsync-simulator:
    location: '.webpack/service' # use webpack build directory
    dynamoDb:
      endpoint: 'http://my-custom-dynamo:8000'

Hot-reloading

By default, the simulator will hot-relad when changes to *.graphql or *.vtl files are detected. Changes to *.yml files are not supported (yet? - this is a Serverless Framework limitation). You will need to restart the simulator each time you change yml files.

Hot-reloading relies on watchman. Make sure it is installed on your system.

You can change the files being watched with the watch option, which is then passed to watchman as the match expression.

e.g.

custom:
  appsync-simulator:
    watch:
      - ["match", "handlers/**/*.vtl", "wholename"] # => array is interpreted as the literal match expression
      - "*.graphql"                                 # => string like this is equivalent to `["match", "*.graphql"]`

Or you can opt-out by leaving an empty array or set the option to false

Note: Functions should not require hot-reloading, unless you are using a transpiler or a bundler (such as webpack, babel or typescript), un which case you should delegate hot-reloading to that instead.

Resource CloudFormation functions resolution

This plugin supports some resources resolution from the Ref, Fn::GetAtt and Fn::ImportValue functions in your yaml file. It also supports some other Cfn functions such as Fn::Join, Fb::Sub, etc.

Note: Under the hood, this features relies on the cfn-resolver-lib package. For more info on supported cfn functions, refer to the documentation

Basic usage

You can reference resources in your functions' environment variables (that will be accessible from your lambda functions) or datasource definitions. The plugin will automatically resolve them for you.

provider:
  environment:
    BUCKET_NAME:
      Ref: MyBucket # resolves to `my-bucket-name`

resources:
  Resources:
    MyDbTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: myTable
      ...
    MyBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: my-bucket-name
    ...

# in your appsync config
dataSources:
  - type: AMAZON_DYNAMODB
    name: dynamosource
    config:
      tableName:
        Ref: MyDbTable # resolves to `myTable`

Override (or mock) values

Sometimes, some references cannot be resolved, as they come from an Output from Cloudformation; or you might want to use mocked values in your local environment.

In those cases, you can define (or override) those values using the refMap, getAttMap and importValueMap options.

  • refMap takes a mapping of resource name to value pairs
  • getAttMap takes a mapping of resource name to attribute/values pairs
  • importValueMap takes a mapping of import name to values pairs

Example:

custom:
  appsync-simulator:
    refMap:
      # Override `MyDbTable` resolution from the previous example.
      MyDbTable: 'mock-myTable'
    getAttMap:
      # define ElasticSearchInstance DomainName
      ElasticSearchInstance:
        DomainEndpoint: 'localhost:9200'
    importValueMap:
      other-service-api-url: 'https://other.api.url.com/graphql'

# in your appsync config
dataSources:
  - type: AMAZON_ELASTICSEARCH
    name: elasticsource
    config:
      # endpoint resolves as 'http://localhost:9200'
      endpoint:
        Fn::Join:
          - ''
          - - https://
            - Fn::GetAtt:
                - ElasticSearchInstance
                - DomainEndpoint

Key-value mock notation

In some special cases you will need to use key-value mock nottation. Good example can be case when you need to include serverless stage value (${self:provider.stage}) in the import name.

This notation can be used with all mocks - refMap, getAttMap and importValueMap

provider:
  environment:
    FINISH_ACTIVITY_FUNCTION_ARN:
      Fn::ImportValue: other-service-api-${self:provider.stage}-url

custom:
  serverless-appsync-simulator:
    importValueMap:
      - key: other-service-api-${self:provider.stage}-url
        value: 'https://other.api.url.com/graphql'

Limitations

This plugin only tries to resolve the following parts of the yml tree:

  • provider.environment
  • functions[*].environment
  • custom.appSync

If you have the need of resolving others, feel free to open an issue and explain your use case.

For now, the supported resources to be automatically resovled by Ref: are:

  • DynamoDb tables
  • S3 Buckets

Feel free to open a PR or an issue to extend them as well.

External functions

When a function is not defined withing the current serverless file you can still call it by providing an invoke url which should point to a REST method. Make sure you specify "get" or "post" for the method. Default is "get", but you probably want "post".

custom:
  appsync-simulator:
    functions:
      addUser:
        url: http://localhost:3016/2015-03-31/functions/addUser/invocations
        method: post
      addPost:
        url: https://jsonplaceholder.typicode.com/posts
        method: post

Supported Resolver types

This plugin supports resolvers implemented by amplify-appsync-simulator, as well as custom resolvers.

From Aws Amplify:

  • NONE
  • AWS_LAMBDA
  • AMAZON_DYNAMODB
  • PIPELINE

Implemented by this plugin

  • AMAZON_ELASTIC_SEARCH
  • HTTP
  • RELATIONAL_DATABASE

Relational Database

Sample VTL for a create mutation

#set( $cols = [] )
#set( $vals = [] )
#foreach( $entry in $ctx.args.input.keySet() )
  #set( $regex = "([a-z])([A-Z]+)")
  #set( $replacement = "$1_$2")
  #set( $toSnake = $entry.replaceAll($regex, $replacement).toLowerCase() )
  #set( $discard = $cols.add("$toSnake") )
  #if( $util.isBoolean($ctx.args.input[$entry]) )
      #if( $ctx.args.input[$entry] )
        #set( $discard = $vals.add("1") )
      #else
        #set( $discard = $vals.add("0") )
      #end
  #else
      #set( $discard = $vals.add("'$ctx.args.input[$entry]'") )
  #end
#end
#set( $valStr = $vals.toString().replace("[","(").replace("]",")") )
#set( $colStr = $cols.toString().replace("[","(").replace("]",")") )
#if ( $valStr.substring(0, 1) != '(' )
  #set( $valStr = "($valStr)" )
#end
#if ( $colStr.substring(0, 1) != '(' )
  #set( $colStr = "($colStr)" )
#end
{
  "version": "2018-05-29",
  "statements":   ["INSERT INTO <name-of-table> $colStr VALUES $valStr", "SELECT * FROM    <name-of-table> ORDER BY id DESC LIMIT 1"]
}

Sample VTL for an update mutation

#set( $update = "" )
#set( $equals = "=" )
#foreach( $entry in $ctx.args.input.keySet() )
  #set( $cur = $ctx.args.input[$entry] )
  #set( $regex = "([a-z])([A-Z]+)")
  #set( $replacement = "$1_$2")
  #set( $toSnake = $entry.replaceAll($regex, $replacement).toLowerCase() )
  #if( $util.isBoolean($cur) )
      #if( $cur )
        #set ( $cur = "1" )
      #else
        #set ( $cur = "0" )
      #end
  #end
  #if ( $util.isNullOrEmpty($update) )
      #set($update = "$toSnake$equals'$cur'" )
  #else
      #set($update = "$update,$toSnake$equals'$cur'" )
  #end
#end
{
  "version": "2018-05-29",
  "statements":   ["UPDATE <name-of-table> SET $update WHERE id=$ctx.args.input.id", "SELECT * FROM <name-of-table> WHERE id=$ctx.args.input.id"]
}

Sample resolver for delete mutation

{
  "version": "2018-05-29",
  "statements":   ["UPDATE <name-of-table> set deleted_at=NOW() WHERE id=$ctx.args.id", "SELECT * FROM <name-of-table> WHERE id=$ctx.args.id"]
}

Sample mutation response VTL with support for handling AWSDateTime

#set ( $index = -1)
#set ( $result = $util.parseJson($ctx.result) )
#set ( $meta = $result.sqlStatementResults[1].columnMetadata)
#foreach ($column in $meta)
    #set ($index = $index + 1)
    #if ( $column["typeName"] == "timestamptz" )
        #set ($time = $result["sqlStatementResults"][1]["records"][0][$index]["stringValue"] )
        #set ( $nowEpochMillis = $util.time.parseFormattedToEpochMilliSeconds("$time.substring(0,19)+0000", "yyyy-MM-dd HH:mm:ssZ") )
        #set ( $isoDateTime = $util.time.epochMilliSecondsToISO8601($nowEpochMillis) )
        $util.qr( $result["sqlStatementResults"][1]["records"][0][$index].put("stringValue", "$isoDateTime") )
    #end
#end
#set ( $res = $util.parseJson($util.rds.toJsonString($util.toJson($result)))[1][0] )
#set ( $response = {} )
#foreach($mapKey in $res.keySet())
    #set ( $s = $mapKey.split("_") )
    #set ( $camelCase="" )
    #set ( $isFirst=true )
    #foreach($entry in $s)
        #if ( $isFirst )
          #set ( $first = $entry.substring(0,1) )
        #else
          #set ( $first = $entry.substring(0,1).toUpperCase() )
        #end
        #set ( $isFirst=false )
        #set ( $stringLength = $entry.length() )
        #set ( $remaining = $entry.substring(1, $stringLength) )
        #set ( $camelCase = "$camelCase$first$remaining" )
    #end
    $util.qr( $response.put("$camelCase", $res[$mapKey]) )
#end
$utils.toJson($response)

Using Variable Map

Variable map support is limited and does not differentiate numbers and strings data types, please inject them directly if needed.

Will be escaped properly: null, true, and false values.

{
  "version": "2018-05-29",
  "statements":   [
    "UPDATE <name-of-table> set deleted_at=NOW() WHERE id=:ID",
    "SELECT * FROM <name-of-table> WHERE id=:ID and unix_timestamp > $ctx.args.newerThan"
  ],
  variableMap: {
    ":ID": $ctx.args.id,
##    ":TIMESTAMP": $ctx.args.newerThan -- This will be handled as a string!!!
  }
}

Requires

Author: Serverless-appsync
Source Code: https://github.com/serverless-appsync/serverless-appsync-simulator 
License: MIT License

#serverless #sync #graphql 

Rahul Jain

Rahul Jain

1597060504

Selenium Grid Tutorial: All About Setting Up A Selenium Grid | LambdaTest

Selenium is by far the most used web automation testing tools. Selenium testing can help you test on major browsers, Operating systems, and even on mobile devices.

But there is a challenge. You have to load so many browsers on your local machine. If you have a windows machine, you cannot test on Safari browsers.

To overcome this challenge you have to test on the platform having different browser environments running multiple test cases concurrently, in parallel, and reducing the overall time.

Here what Selenium Grid comes which allow you to run the test in different browser/versions, simultaneously.

Let us get a deep study on it!!

#seleniumtesting #seleniumgrid #seleniumwebdriver #developer #automationtesting #opensource #tutorial #browsertesting #safari #testing

#automation #selenium #selenium-grid #testing #selenium-webdriver

Ilene  Jerde

Ilene Jerde

1596801420

Selenium Tool Suite - Components and Features

Selenium is an automation testing tool; it is primarily used to test websites and web applications; it is an open-source tool. With the help of Selenium, test cases can run directly in web browsers, just like a person operating the web browsers. It supports many web browsers such as Opera, Safari, Chrome, Firefox, IE, etc. There are several different sub tools to support different automation test approaches. In this article, we will learn about selenium tool suite, its components and features. So let’s start!!!

#selenium tutorials #selenium grid #selenium ide #selenium rc #selenium tool suite #selenium webdriver

Anthony  Dach

Anthony Dach

1647135120

Selenium Grid Extras: Helps Set Up & Manage Your Local Selenium Grid

Selenium-Grid-Extras

Selenium Grid Extras is a project that helps you set up and manage your local Selenium Grid. Typical instances of the Grid consists of the HUB and Nodes. The HUB is responsible for managing test sessions and assigning new session idle nodes.

Setup of Grid Extras is made to be simple, just run the packaged JAR file and point the node at the HUB location, Grid Extras will take care of the rest for you. Here are the features you get by using Selenium Grid Extras vs Selenium Grid alone:

  • Ability to control individual grid nodes, following is an incomplete list of OS level tasks:
    • Killing any browser instance by name
    • Stopping any Process by PID
    • Moving mouse to specific location
    • Get Memory usage and disk statistics
  • Automatically upgrade WebDriver binaries
  • Restart node after a set number of test executions
  • Central storage of configurations for all nodes on the HUB server
  • Screenshots at the OS level
  • And much more.

Running

  1. On the initial execution, follow the "Setup Instructions" section.
  2. As part of the initial execution, a starter script start_grid_extras.sh or start_grid_extras.bat will be generated.
  3. After the initial execution, use the generated start script to start HUB or nodes thereafter.
    • This will help with automatic upgrades and downgrades
    • Be careul of putting the Selenium Grid Extras jar file in a directory with spaces. Doing so may cause issues. PR welcome to fix this.

Setup Instructions

Setup is simple, just download the Grid Extras Jar to get started from here: Download Latest

Setting up Grid Hub

  1. In the terminal run following command:
java -jar Selenium-Grid-Extras-Jar.jar

2.   You will be prompted with several questions, first one will ask you if you want to set this computer as a HUB, Node, or both. Answer 2 for HUB

3.   Leave the Host name for Grid Hub as default 127.0.0.1

4.   Set port to be used by Selenium Grid Hub, default is 4444

5.   You will be asked if you wish to auto update Selenium. If you answer yes, then every time Selenium Grid Extras is started it will check fo the latest version of Selenium Stand Alone Server, IEDriver, and ChromeDriver. If you choose to not auto update, you will be asked what versions of each driver to lock into.

Setting up Grid Node

  1. In the terminal run following command:
java -jar Selenium-Grid-Extras-Jar.jar

2.   You will be asked if you wish to use this computer as HUB or Node, select 1 for Node

3.   You will be asked for the host name of the HUB computer, type in the IP or hostname of the HUB computer

4.   When prompted for the port used by the HUB, enter that value

5.   Selenium Grid Extras will attempt to guess the Operating System of the current computer, if it's wrong please enter the correct value

6.   You will be asked what Browsers this Node will host, choose the ones that apply

7.   You will be asked how often to restart your whole computer. By default after 10 tests Selenium Grid Extras will attempt to restart the Node, provided the node is idle. Choose 0 if you do not wish to have the computer automatically restart.

8.   You will be asked if Selenium Grid Extras should automatically check for updates of IEDriver, ChromeDriver and Selenium Stand Alone Server. If you answer no, you will be asked what version to lock into.

9.   Finally, you will be asked if you wish to store all of the Node configs on the HUB. If you answer yes, Selenium Grid Extras will attempt to push Node's configs to the HUB. If it is successful, Selenium Grid Extras will attempt to download all of the configs from the HUB before it starts. This way all of the Node configs can be controlled directly from the HUB.

Changing the logging on the grid hub, nodes, or selenium-grid-extras

  1. For grid extras, create a log4j.properties in the same directory as your jar file. Start the service like : java -Dlog4j.debug -Dlog4j.configuration=file:log4j.properties -cp .:SeleniumGridExtras-1.10.0-SNAPSHOT-jar-with-dependencies.jar com.groupon.seleniumgridextras.SeleniumGridExtras (Use a semi-colon in the classpath for Windows. Use a colon in the classpath for Mac/Linux).
  2. For hub and node log files, add the following to the selenium_grid_extras_config.json file (see selenium_grid_extras_config.json.example for an example):
    "grid_jvm_options": {
    "selenium.LOGGER.level": "WARNING"
    },
     

Upgrading Grid Extras

There are 2 options available for un-attended upgrades

  1. Automatic upgrades can be achieved by selected "auto update" on the first run, or setting "grid_extras_auto_update" key to have value of "1" in selenium_grid_extras_config.json
  2. Manual upgrade trigger can be achieved by making an HTTP GET request against http://node_name:3000/upgrade_grid_extras?version=X.X.X

Auto Restarting Nodes

Starting with release 1.3.0 the nodes have an option of automatically restarting after a certain amount of builds have been executed and the node is currently not busy. This helps to keep the nodes in pristine state for longer periods of time, and clears up and browser crashes, which may have occurred. Some setup will be needed to make this feature work as intended.

  1. Setup default login user
  2. Setup default start up task
  3. Give permission to access OS.
shutdown -r -t 1 -f

Windows

  1. Follow Microsoft's Technical Help
  2. Add start up batch script to StartUp directory or set up a Scheduled Task to start the batch file automatically
  3. No need to setup permission as long as current user can run the following command in the Terminal

OS X

  1. Turn on Automatic Login option and make the desired user auto login
  2. Set up the shell script which starts Grid Extras to run automatically.
  3. Modify the /etc/sudoers to contain this line, where the $USER is the current user that will be used for running grid node.
$USER ALL=(ALL) NOPASSWD: /sbin/shutdown

Linux

  1. ...
  2. Set up the shell script which starts Grid Extras to run automatically.
  3. Modify the /etc/sudoers to contain this line, where the $USER is the current user that will be used for running grid node.
$USER ALL=(ALL) NOPASSWD: /sbin/shutdown

Starting Services

Note: Make sure to run Grid Extras at least once prior to setting it up as a service, so it can ask you the first run questions.

Windows

There are two major ways to make windows automatically start the Grid Extras binary

  • Insert a batch file into StartUp directory
  • Using the Task Scheduler to add the java start command, where the executable will be the path to java.exe and the path to Grid Extras passed in as an argument

Linux

There are a lot of security issues with setting up a cron job as a “build user” and letting that user run in the normal display desktop (DISPLAY=:0 aka the one you see when it is connected to the computer monitor). There is a work around to allow the service to run in DISPLAY=:0 but that’s not recommended.

Instead, it is a much better practice to set up a XVNC server on a Linux computer, with a light desktop manager (FluxBox seems to be a good lightweight choice http://fluxbox.org/). Once VNC server and desktop managers are installed, run the following command to start a virtual DISPLAY:

vncserver :1 -geometry 1024x768

This will start an XVNC server on DISPLAY=:1 with screen resolution of 1024x768. You can tweak these parameters as needed. Note: You might need to add a cron job to restart vncserver in similar fashion, since vncserver will not automatically start after reboot

After you have the virtual display running, add run this command to edit the cron list for current user (vi is the editor used)

crontab -e

Add following lines to the cron list:

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
*/5 * * * * bash -i -c 'cd WORKING_DIRECTORY; export DISPLAY=:1 java -jar SELENIUM_GRID_EXTRAS.jar' >> WORKING_DIRECTORY/log/log.out 2>&1

Where the WORKING_DIRECTORY needs to be replaced with the location where grid extras jar was downloaded, and SELENIUM_GRID_EXTRAS represents the name given to the grid extras jar. This cron will run every 5 minutes.

OS X

Download the SeleniumGridExtras.plist to your computer, open it in editor of choice.

Update the XML file replacing WORKING_DIRECTORY with the location of the selenium grid extras working directory Update the XML file replacing SELENIUM_GRID_EXTRAS.jar with the name Selenium Grid Extras was saved as

Move the com.groupon.SeleniumGridExtras.plist to ~/Library/LaunchAgents/

run

launchctl load ~/Library/LaunchAgents/com.groupon.SeleniumGridExtras.plist

Debugging most common Selenium Grid Test failures

Docker Images

https://github.com/viltgroup/docker-selenium-grid-extras provided by @mariolameiras . If you see any issues with these images please report them on the https://github.com/viltgroup/docker-selenium-grid-extras repo, and not this repo. These are new images, so please keep that in mind.

Contributing

For This project, add functionality, make sure all tests pass, send pull request.

Note: This product exposes your machine to the whole network, anyone on the network will be able to perform OS level task by simply hitting an HTTP url. There are no security measures at the moment, and at the moment no plans to add any security. You have been warned!

Link Backs

This project uses jWMI.java which was taken from www.henryranch.net

Download Details:
Author: groupon
Source Code: https://github.com/groupon/Selenium-Grid-Extras
License: BSD-3-Clause License

#selenium #ruby #java 

Anthony  Dach

Anthony Dach

1642862940

Selenium Grid Extras: Helps Set Up & Manage Your Local Selenium Grid

Selenium-Grid-Extras

Selenium Grid Extras is a project that helps you set up and manage your local Selenium Grid. Typical instances of the Grid consists of the HUB and Nodes. The HUB is responsible for managing test sessions and assigning new session idle nodes.

Setup of Grid Extras is made to be simple, just run the packaged JAR file and point the node at the HUB location, Grid Extras will take care of the rest for you. Here are the features you get by using Selenium Grid Extras vs Selenium Grid alone:

  • Ability to control individual grid nodes, following is an incomplete list of OS level tasks:
    • Killing any browser instance by name
    • Stopping any Process by PID
    • Moving mouse to specific location
    • Get Memory usage and disk statistics
  • Automatically upgrade WebDriver binaries
  • Restart node after a set number of test executions
  • Central storage of configurations for all nodes on the HUB server
  • Screenshots at the OS level
  • And much more.

Running

  1. On the initial execution, follow the "Setup Instructions" section.
  2. As part of the initial execution, a starter script start_grid_extras.sh or start_grid_extras.bat will be generated.
  3. After the initial execution, use the generated start script to start HUB or nodes thereafter.
    • This will help with automatic upgrades and downgrades
    • Be careul of putting the Selenium Grid Extras jar file in a directory with spaces. Doing so may cause issues. PR welcome to fix this.

Setup Instructions

Setup is simple, just download the Grid Extras Jar to get started from here: Download Latest

Setting up Grid Hub

  1. In the terminal run following command:
java -jar Selenium-Grid-Extras-Jar.jar

2.   You will be prompted with several questions, first one will ask you if you want to set this computer as a HUB, Node, or both. Answer 2 for HUB

3.   Leave the Host name for Grid Hub as default 127.0.0.1

4.   Set port to be used by Selenium Grid Hub, default is 4444

5.   You will be asked if you wish to auto update Selenium. If you answer yes, then every time Selenium Grid Extras is started it will check fo the latest version of Selenium Stand Alone Server, IEDriver, and ChromeDriver. If you choose to not auto update, you will be asked what versions of each driver to lock into.

Setting up Grid Node

  1. In the terminal run following command:
java -jar Selenium-Grid-Extras-Jar.jar

2.   You will be asked if you wish to use this computer as HUB or Node, select 1 for Node

3.   You will be asked for the host name of the HUB computer, type in the IP or hostname of the HUB computer

4.   When prompted for the port used by the HUB, enter that value

5.   Selenium Grid Extras will attempt to guess the Operating System of the current computer, if it's wrong please enter the correct value

6.   You will be asked what Browsers this Node will host, choose the ones that apply

7.   You will be asked how often to restart your whole computer. By default after 10 tests Selenium Grid Extras will attempt to restart the Node, provided the node is idle. Choose 0 if you do not wish to have the computer automatically restart.

8.   You will be asked if Selenium Grid Extras should automatically check for updates of IEDriver, ChromeDriver and Selenium Stand Alone Server. If you answer no, you will be asked what version to lock into.

9.   Finally, you will be asked if you wish to store all of the Node configs on the HUB. If you answer yes, Selenium Grid Extras will attempt to push Node's configs to the HUB. If it is successful, Selenium Grid Extras will attempt to download all of the configs from the HUB before it starts. This way all of the Node configs can be controlled directly from the HUB.

Changing the logging on the grid hub, nodes, or selenium-grid-extras

  1. For grid extras, create a log4j.properties in the same directory as your jar file. Start the service like : java -Dlog4j.debug -Dlog4j.configuration=file:log4j.properties -cp .:SeleniumGridExtras-1.10.0-SNAPSHOT-jar-with-dependencies.jar com.groupon.seleniumgridextras.SeleniumGridExtras (Use a semi-colon in the classpath for Windows. Use a colon in the classpath for Mac/Linux).
  2. For hub and node log files, add the following to the selenium_grid_extras_config.json file (see selenium_grid_extras_config.json.example for an example):
    "grid_jvm_options": {
    "selenium.LOGGER.level": "WARNING"
    },
     

Upgrading Grid Extras

There are 2 options available for un-attended upgrades

  1. Automatic upgrades can be achieved by selected "auto update" on the first run, or setting "grid_extras_auto_update" key to have value of "1" in selenium_grid_extras_config.json
  2. Manual upgrade trigger can be achieved by making an HTTP GET request against http://node_name:3000/upgrade_grid_extras?version=X.X.X

Auto Restarting Nodes

Starting with release 1.3.0 the nodes have an option of automatically restarting after a certain amount of builds have been executed and the node is currently not busy. This helps to keep the nodes in pristine state for longer periods of time, and clears up and browser crashes, which may have occurred. Some setup will be needed to make this feature work as intended.

  1. Setup default login user
  2. Setup default start up task
  3. Give permission to access OS.

Windows

  1. Follow Microsoft's Technical Help
  2. Add start up batch script to StartUp directory or set up a Scheduled Task to start the batch file automatically
  3. No need to setup permission as long as current user can run the following command in the Terminal
shutdown -r -t 1 -f

OS X

  1. Turn on Automatic Login option and make the desired user auto login
  2. Set up the shell script which starts Grid Extras to run automatically.
  3. Modify the /etc/sudoers to contain this line, where the $USER is the current user that will be used for running grid node.
$USER ALL=(ALL) NOPASSWD: /sbin/shutdown

Linux

  1. ...
  2. Set up the shell script which starts Grid Extras to run automatically.
  3. Modify the /etc/sudoers to contain this line, where the $USER is the current user that will be used for running grid node.
$USER ALL=(ALL) NOPASSWD: /sbin/shutdown

Starting Services

Note: Make sure to run Grid Extras at least once prior to setting it up as a service, so it can ask you the first run questions.

Windows

There are two major ways to make windows automatically start the Grid Extras binary

  • Insert a batch file into StartUp directory
  • Using the Task Scheduler to add the java start command, where the executable will be the path to java.exe and the path to Grid Extras passed in as an argument

Linux

There are a lot of security issues with setting up a cron job as a “build user” and letting that user run in the normal display desktop (DISPLAY=:0 aka the one you see when it is connected to the computer monitor). There is a work around to allow the service to run in DISPLAY=:0 but that’s not recommended.

Instead, it is a much better practice to set up a XVNC server on a Linux computer, with a light desktop manager (FluxBox seems to be a good lightweight choice http://fluxbox.org/). Once VNC server and desktop managers are installed, run the following command to start a virtual DISPLAY:

vncserver :1 -geometry 1024x768

This will start an XVNC server on DISPLAY=:1 with screen resolution of 1024x768. You can tweak these parameters as needed. Note: You might need to add a cron job to restart vncserver in similar fashion, since vncserver will not automatically start after reboot

After you have the virtual display running, add run this command to edit the cron list for current user (vi is the editor used)

crontab -e

Add following lines to the cron list:

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
*/5 * * * * bash -i -c 'cd WORKING_DIRECTORY; export DISPLAY=:1 java -jar SELENIUM_GRID_EXTRAS.jar' >> WORKING_DIRECTORY/log/log.out 2>&1

Where the WORKING_DIRECTORY needs to be replaced with the location where grid extras jar was downloaded, and SELENIUM_GRID_EXTRAS represents the name given to the grid extras jar. This cron will run every 5 minutes.

OS X

Download the SeleniumGridExtras.plist to your computer, open it in editor of choice.

Update the XML file replacing WORKING_DIRECTORY with the location of the selenium grid extras working directory Update the XML file replacing SELENIUM_GRID_EXTRAS.jar with the name Selenium Grid Extras was saved as

Move the com.groupon.SeleniumGridExtras.plist to ~/Library/LaunchAgents/

run

launchctl load ~/Library/LaunchAgents/com.groupon.SeleniumGridExtras.plist

Debugging most common Selenium Grid Test failures

Docker Images

https://github.com/viltgroup/docker-selenium-grid-extras provided by @mariolameiras . If you see any issues with these images please report them on the https://github.com/viltgroup/docker-selenium-grid-extras repo, and not this repo. These are new images, so please keep that in mind.

Contributing

For This project, add functionality, make sure all tests pass, send pull request.

Note: This product exposes your machine to the whole network, anyone on the network will be able to perform OS level task by simply hitting an HTTP url. There are no security measures at the moment, and at the moment no plans to add any security. You have been warned!

Link Backs

This project uses jWMI.java which was taken from www.henryranch.net

Download Details:
Author: groupon
Source Code: https://github.com/groupon/Selenium-Grid-Extras
License: BSD-3-Clause License

#selenium  #java #ruby