Skip to content

Selenium

What's difference between Selenium3 and Selenium4?

How dose appium register at grid node between selenium3 and selenium4?

  • Selenium3
  • Appium server can be registered by --node-config server parameter. In the node config file you have to define the browserName, version and platform and based on these parameters the gird will redirect your test to the right device. Example for appium --node-config

    selenium3-register-node

  • Selenium4

  • Appium no longer needs to use --node-config server parameter to register at gird node. Instead, selenium4 adds new feature Relay allows you to proxy Appium requests to an appium server instance.

    selenium4-register-node

  • As mentioned before, appium no longer use --node-config, but we have to define the node-config for selenium-node. The node-config use toml format for config file which consists of sections and each sections has options and its respective values.

    # This is an example for node-config.toml
    
    [server]
    port = 5555
    
    [node]
    detect-drivers = false
    
    
    [relay]
    url = "http://localhsot:4723/wd/hub"
    status-endpoint = "/status"
    configs = [
        "1", "{\"browserName\":\"Safari\", \"platformName\": \"iOS\"}"
    ]
    
  • Note: Strongly recommend watching this appium conference which explains how selenium gird work and why selenium4 has relay feature

Getting Started with Selenium Grid

  • Before starting selenium grid, you have to setup the environment. Please refer to here

  • Download the selenium server and move it to /opt directory

  • Start Selenium Hub

  • Open the new terminal and typing the below commands

    # Get ip address
    IP_ADDR=$( ip route get 1.2.3.4 | awk -F " " '{print $7}' )
    
    # Start Hub
    java -jar /opt/selenium-server-4.4.0.jar hub\
        --publish-events tcp://${IP_ADDR}:4442\
        --subscribe-events tcp://${IP_ADDR}:4443\
        --port 4444\
        --session-request-timeout 60\
        --healthcheck-interval 60\
        --allow-cors true
    
  • Note: Add parameter --log-level FINEST to adjust the log level for helping debug

start-selenium-hub
  • Start Appium

  • Open the new terminal and typing the below command

    appium -p 4723 \
        --relaxed-security \
        --session-override \
        -ka 300
    
  • Note: If you want to test chrome on your device, you need to download the chrome driver which must confirm the browser version of your device. After downloading the chrome driver, you need to add --chromedriver-executable ${DRIVER_PATH} while starting the appium server.

    start-appium

  • Start Selenium Node

  • Open the new terminal and typing the below command

    # Get ip address
    IP_ADDR=$( ip route get 1.2.3.4 | awk -F " " '{print $7}' )
    
    # Start Node
    java -jar /opt/selenium-server-4.4.0.jar node\
        --publish-events tcp://${IP_ADDR}:4442\
        --subscribe-events tcp://${IP_ADDR}:4443\
        --port 5555\
        --max-sessions 8\
        --config "$( pwd )/node_config.toml"
    
    • Note: If selenium hub start on the another machine, the ${IP_ADDR} should be set hub machine ip address. And ensure the two machine network can communicate with each other
  • Check the each terminal after register

  • Selenium Hub

    selenium-hub

  • Selenium Node

    selenium-node

  • Open http://localhost:4444/ui

    selenium-ui

Reference