Zalenium Docker with LambdaTest

I am trying to setup LambdaTest in the Zalenium Docker. I have followed the steps mentioned in Zalenium - A flexible and scalable Selenium Grid. to setup the Zalenium docker and it was installed successfully.

However, when I try to use LambdaTest with Zalenium docker, I get 401 unauthorized error. I am running all the commands mentioned below as an administrator

These are steps that I have followed so far:

  1. Pull the docker image of the Lambda Tunnel by running the command (Source - Localhost Testing With Docker Tunnel | LambdaTest)

docker pull lambdatest/tunnel:latest

  1. Set the required environment variables mentioned in the LambdaTest Zalenium setup page:

set LT_USERNAME= “user.name” set LT_ACCESS_KEY=“access.key” set LT_URL=“https://user.name:access.key@hub.lambdatest.com/wd/hub:9002”

I am using the port number as 9002.

  1. Followed the steps mentioned on the Zalenium site (for using the Zalenium Docker with LambdaTest):

Same steps are also mentioned here.

Once I run the command, I get the error as shown below:

Looks like the authorization is not going through. Can the LamdaTest team help me figure this out since it is blocking the usage of the Zalenium docker.

Thanks in advance.

4 Likes

Thanks, Himanshu for bringing this to our notice. We are looking into it at our end. :slightly_smiling_face:

3 Likes

Hello Himanshu

Could you please define your LT_ACCESS_KEY and LT_USERNAME in your environment variables like this

and then connecting through this command:

docker run --rm -ti --name zalenium -p 4444:4444 -e LT_USERNAME -e LT_ACCESS_KEY -e https://hub.lambdatest.com/wd/hub -v /tmp/videos:/home/seluser/videos -v /var/run/docker.sock:/var/run/docker.sock --privileged dosel/zalenium start --lambdaTestEnabled true

2 Likes

Thanks for the reply, it worked after I set the required details via Cygwin

export LT_USERNAME=user-name export LT_ACCESS_KEY=access-key export LT_URL=https://hub.lambdatest.com/wd/hub:

Once these are set, I run the following command:

docker run --rm -ti --name zalenium -p 4447:4444 -e LT_USERNAME -e LT_ACCESS_KEY -e LT_URL -v /c/Test_Videos:/home/seluser/videos -v /var/run/docker.sock:/var/run/docker.sock --privileged dosel/zalenium start --lambdaTestEnabled true

where recorded test video is available in C:\Test_Videos

Assuming that I am server is running at port 4447 and I want to use the LambdaTest capabilities (e.g. Safari 13.0 on MacOS Catalina), is it possible to do it with the Docker? If so, please share the code snippet.

I am currently using LambdaTest with Docker in the following manner:

public void setupLTCombination (String build, String name, String platformName,
                                    String browserName, String browserVersion) throws MalformedURLException
    {
        DesiredCapabilities capabilities = new DesiredCapabilities();

        capabilities.setCapability("build", build);
        capabilities.setCapability("name", name);
        capabilities.setCapability("platformName", platformName);
        capabilities.setCapability("browserName", browserName);
        capabilities.setCapability("browserVersion",browserVersion);
        capabilities.setCapability("tunnel",false);
        capabilities.setCapability("network",true);
        capabilities.setCapability("console",true);
        capabilities.setCapability("visual",true);
        String[] customTags = {""};
        customTags[0] = platformName + " " + browserName + " " + browserVersion;
        /* Setting Custom Tags */
        capabilities.setCapability("tags", customTags);
        /* End - Setting Custom Tags */

        //This will not be hardcoded to Chrome for Safari (and other browsers), it is only for reference
         ChromeOptions options = new ChromeOptions();
        //driver.set(new RemoteWebDriver(new URL("http://" + username + ":" + access_key + "@hub.lambdatest.com/wd/hub"), capabilities));
        driver.set(new RemoteWebDriver(new URL(remote_url), options));
    }

where remote_url is set to “http://localhost:4447/wd/hub” I have installed the Selenium Hub and Firefox & Chrome nodes in the Hub but I wanted to check if I can run the test in Docker for other browser & OS combinations (using LambdaTest).

Here is what I see in the Grid Console

As expected, tests work fine with Firefox and Chrome (using Desired Capabilities or Options) but how I can use LambdaTest and Docker for other browser and OS combinations?

3 Likes

Himanshu, seems to be you can do that by changing browser and platform in desired capabilities

1 Like

Hi LambdaTest Team, Is there any update on this front?

1 Like

I am sharing a sample. Please try defining the URL like this

URL url= new URL("http://localhost:4444/wd/hub");

driver = new RemoteWebDriver(url,capabilities);

Please let me know if this works for you.

Thanks

3 Likes

Hello Himanshu,

Could you please try using this to code to run zalenium rather than using LT_URL

docker run --rm -ti --name zalenium -p 4444:4444 -e LT_USERNAME -e LT_ACCESS_KEY -e https://hub.lambdatest.com/wd/hub -v /tmp/videos:/home/seluser/videos -v /var/run/docker.sock:/var/run/docker.sock --privileged dosel/zalenium start --lambdaTestEnabled true

4 Likes

@sakshama Bit late in replying, I could finally come up with a detailed blog on How to run Selenium Tests in Docker where I added a separate section on leveraging cloud-based Selenium Grid and Docker to expedite the automation testing process.

Thanks for your support.

1 Like