<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Selenium Grid - Medium]]></title>
        <description><![CDATA[I will be setting up Selenium Grid and execute a pytest selenium script - Medium]]></description>
        <link>https://medium.com/selenium-grid-on-gcp?source=rss----62ce0b3d337c---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Selenium Grid - Medium</title>
            <link>https://medium.com/selenium-grid-on-gcp?source=rss----62ce0b3d337c---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 17:41:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/selenium-grid-on-gcp" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Jenkins pipeline + Selenium Grid + Docker]]></title>
            <link>https://medium.com/selenium-grid-on-gcp/jenkins-pipeline-selenium-grid-docker-a2ba61ef0d42?source=rss----62ce0b3d337c---4</link>
            <guid isPermaLink="false">https://medium.com/p/a2ba61ef0d42</guid>
            <category><![CDATA[jenkinsfile]]></category>
            <category><![CDATA[jenkins-pipeline]]></category>
            <category><![CDATA[selenium-grid]]></category>
            <category><![CDATA[allure]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Ben Jose]]></dc:creator>
            <pubDate>Mon, 23 Mar 2020 16:36:19 GMT</pubDate>
            <atom:updated>2020-03-25T03:31:22.173Z</atom:updated>
            <content:encoded><![CDATA[<p>In this story, I will be setting up Jenkins pipeline to execute a pytest selenium script on a Selenium Grid hub using Docker compose</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*DXt8TeNFvAIInzCIMEKB3Q.png" /></figure><p><strong>Stage 1: Install Jenkins, Docker and Docker Compose</strong></p><p>Follow this <a href="https://medium.com/selenium-grid-on-gcp/jenkins-pytest-selenium-grid-docker-compose-gcp-allure-32c1c4db744d">link</a> for details. (Stage 1 and 2 in the link)</p><p><strong>Stage 2: Setting up Jenkins</strong></p><p>Navigate to <strong>Site address</strong>(refer above mentioned stage). Login using ‘<strong>Admin user</strong>’ and ‘<strong>Admin password</strong>’. The page them navigates to Jenkins Dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/0*-ijVnsGGZudyoecr.png" /></figure><p><strong>Install Allure plugin</strong>. From Jenkins main window navigate to Manage Jenkins → Manage Plugins → Available(Tab) → Search for Allure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/0*SwuXgAVwKYIbAJqu.png" /></figure><p>Manage Jenkins → Manage Plugins</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QLx3S7Eb2uSWSTOj.png" /></figure><p>Click on <strong>“Download now and install after restart”</strong></p><p>Setting up <strong>Allure Commandline</strong>. From Jenkins main window navigate to Manage Jenkins → Global Tool Configuration → Scroll down and find Allure Commandline and set the commandline as ‘Allure’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/0*Aq8qkrqILJpsQTnM.png" /></figure><p>Manage Jenkins → Global Tool Configuration</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iTd3nQ38IE1myt0l.png" /></figure><p><strong>Create Jenkins project</strong>. From Jenkins main window click on ‘<strong>New Item</strong>’.</p><p>Enter the name of the project and select <strong>Pipeline</strong>. Click OK to continue</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o4eeqzw7IMpes3gCokmyHQ.png" /></figure><p>On the next window, scroll down to <strong>Advanced Project Options</strong>. Select Definition : <strong>Pipeline script from SCM</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h9Y8JYBB59Pr3QiTH8ofMg.png" /></figure><p>Select SCM : <strong>Git</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I-3M8DJZ72hIWkzYHyqigQ.png" /></figure><p>Set reporitory URL — <a href="https://gitlab.com/benjose22/pytest_selenium.git">https://gitlab.com/benjose22/pytest_selenium.git</a></p><p>Set Script Path — compose.Jenkinsfile</p><p>compose.Jenkinsfile can be found at git location <a href="https://gitlab.com/benjose22/pytest_selenium/-/blob/master/compose.Jenkinsfile">here</a>. The pipeline script consist of six stages.</p><pre>/* Cloning the git branch*/<br>stage(&#39;Clone repository&#39;) {<br>        checkout scm<br>}<br></pre><pre>/* Start docker-compose with five instances of Chrome */<br>stage(&#39;Start docker-compose&#39;) {	<br>	sh &#39;docker-compose up -d --scale chrome=5 --scale firefox=0&#39;<br>}</pre><pre>	<br>/* This builds an image with all pytest selenium scripts in it */<br>stage(&#39;Build image&#39;) {<br>		def dockerfile = &#39;pytest.Dockerfile&#39;<br>        app = docker.build(&quot;pytest-with-src&quot;,&quot;-f ${dockerfile} ./&quot;)<br>}<br>	</pre><pre>/* Execute the pytest script. Even on faliure proceed to next step */<br>stage(&#39;Execute script&#39;) {<br>        catchError(buildResult: &#39;SUCCESS&#39;, stageResult: &#39;FAILURE&#39;) {<br>            sh &#39;docker run --network=&quot;host&quot; --rm -i -v ${WORKSPACE}/allure-results:/AllureReports pytest-with-src --executor &quot;remote&quot; --browser &quot;chrome&quot; .&#39;<br>        }<br>}<br>	</pre><pre>/* Delete the image which got created earlier */<br>stage(&#39;Remove image&#39;) {<br>        sh &#39;docker rmi pytest-with-src -f&#39;<br>}<br>   <br> <br>/* Tear down docker compose */<br>stage(&#39;Teardown docker-compose&#39;) {<br>        sh &#39;docker-compose down --rmi local&#39;<br>}<br>  <br>  <br>/* Generate Allure Report */<br>stage(&#39;Allure Report&#39;) {<br>        allure includeProperties: false, jdk: &#39;&#39;, results: [[path: &#39;allure-results&#39;]]<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FqIKSK9jYa5Yq7_VcUFSNA.png" /></figure><p>Click on ‘<strong>Save</strong>’ and the pipeline is created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WLrgiVWS7XF7ifyHM-W5sg.png" /></figure><p>Click on “Build Now” to start the build. You can see the progress of the build in “Build history”.</p><p>Once the build is completed, we can see the stats as below —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/0*hEEGvEHgWaKoyOIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J6Mb-QNA5XKwWLYoZxN2-Q.png" /><figcaption>Dashboard once the run is complete</figcaption></figure><p>Note that the error(red Dot) you see are intentional so dont get panic :)</p><p>Click on “Allure Report” to see the results —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J9t6EarwO1osAyFv.png" /><figcaption>Allure main dashboard</figcaption></figure><p>You can further drill down to see testcase description, error details, screenshots etc</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r41jonHR10cH_ztT.png" /></figure><p>If you enable Blue Ocean plugin(from Manage Jenkins → Manage Plugins ), you get a better view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8uhsfs8d-ErRczdzPKzZXg.png" /><figcaption>View looks better with Blue Ocean</figcaption></figure><p>Hope you enjoyed the story. Please share your feedback for improvements.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2ba61ef0d42" width="1" height="1" alt=""><hr><p><a href="https://medium.com/selenium-grid-on-gcp/jenkins-pipeline-selenium-grid-docker-a2ba61ef0d42">Jenkins pipeline + Selenium Grid + Docker</a> was originally published in <a href="https://medium.com/selenium-grid-on-gcp">Selenium Grid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jenkins + Pytest + Selenium Grid + Docker Compose + GCP + Allure]]></title>
            <link>https://medium.com/selenium-grid-on-gcp/jenkins-pytest-selenium-grid-docker-compose-gcp-allure-32c1c4db744d?source=rss----62ce0b3d337c---4</link>
            <guid isPermaLink="false">https://medium.com/p/32c1c4db744d</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[selenium-grid]]></category>
            <category><![CDATA[allure]]></category>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ben Jose]]></dc:creator>
            <pubDate>Tue, 18 Feb 2020 04:46:44 GMT</pubDate>
            <atom:updated>2020-03-23T14:59:26.411Z</atom:updated>
            <content:encoded><![CDATA[<p>In this story I will be setting up Jenkins on GCP to execute a Pytest python selenium script on Selenium Grid using Docker Compose. Finally the report will be in Allure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*4JhNiPRPLRPQpoa9JTC6hw.jpeg" /></figure><p><strong>Stage 1: Setting up a Jenkins VM on GCP</strong></p><p>Login to <a href="https://cloud.google.com/">GCP </a>and search for Jenkins in the main search textbox.</p><p>Choose “Google Click to Deploy” Jenkins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oUrAt07Ej8gNksS1xtYdiQ.png" /></figure><p>On the next window click on <strong>“LAUNCH ON COMPUTE ENGINE”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*ch_R2rZfw74CLXOnT4kXUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*Kdp5TycKMEehMJV5YxwaCQ.png" /><figcaption>my Jenkins VM configuration</figcaption></figure><p>Wait for couple of minutes for the VM to get provisioned. After that you will get the window(below screenshot) which has the Jenkins site address, username and password to access it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WRbazJvdu5i74joGK8to1Q.png" /></figure><p><strong>Stage 2: Setup Docker and Docker Compose</strong></p><p>On the same window(above screenshot), we get an option to SSH to the VM. Lets go to the VM via commandline. Click on “<strong>Open in browser window</strong>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*VorniEfG-gH5Aes5hKpmMQ.png" /></figure><p>You will get the terminal like this —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*iY3t-Psh9bhBsl8JJHreDg.png" /></figure><p>Install Docker —</p><pre>curl -fsSL https://get.docker.com -o get-docker.sh<br>sh get-docker.sh<br>sudo groupadd docker<br>sudo usermod -aG docker $USER<br>newgrp docker<br>docker --version</pre><p>Install Docker Compose —</p><pre>sudo curl -L &quot;https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)&quot; -o /usr/local/bin/docker-compose<br>sudo chmod +x /usr/local/bin/docker-compose<br>sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose<br>docker-compose --version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*afvoLtsTgrXyOXVEqLGsfQ.png" /></figure><p><strong>Stage 3: Setting up Jenkins</strong></p><p>Navigate to <strong>Site address</strong>(refer earlier screenshot). Login using ‘<strong>Admin user</strong>’ and ‘<strong>Admin password</strong>’. The page them navigates to Jenkins Dashboard. (Note that, if you are familiar with Jenkins setup, you would have observed a plugin manager window is missing.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*QmYiMcOIytnKZs8lG6Dc0A.png" /></figure><p><strong>Install Allure plugin</strong>. From Jenkins main window navigate to Manage Jenkins → Manage Plugins → Available(Tab) → Search for Allure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*GDInXhUEcv1aOAeHH8mlPA.png" /><figcaption>Manage Jenkins → Manage Plugins</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tqomuaIM90eqp3NtJ6C2Og.png" /></figure><p>Click on <strong>“Download now and install after restart”</strong></p><p>Setting up <strong>Allure Commandline</strong>. From Jenkins main window navigate to Manage Jenkins → Global Tool Configuration → Scroll down and find Allure Commandline and set the commandline as ‘Allure’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*vkWmKt7xYbqKtIbJcgRt9Q.png" /><figcaption>Manage Jenkins → Global Tool Configuration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A5PUT1tsERBnvB0zIJTUqA.png" /></figure><p><strong>Create Jenkins project</strong>. From Jenkins main window click on ‘New Item’.</p><p>Enter the name of the project and select Freestyle project. Click OK to continue</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wn4UY_N7FLSqt1bXpyhEwA.png" /></figure><p>On the next window, scroll down to Source Code Management. Select the Git repository.</p><p>Set reporitory URL — <a href="https://gitlab.com/benjose22/pytest_selenium.git">https://gitlab.com/benjose22/pytest_selenium.git</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wVH9sz3vrotofgvlpdlYmQ.png" /></figure><p>Scroll down to ‘Build’ and choose “Execute Shell” in Add Build Step. Add below code to execute in Jenkins Job.</p><pre>docker-compose up -d --scale chrome=5 --scale firefox=0<br>docker build -t pytest-with-src -f pytest.Dockerfile .<br>docker run --network=&quot;host&quot; --rm -i -v ${WORKSPACE}/allure-results:/AllureReports pytest-with-src --executor &quot;remote&quot; --browser &quot;chrome&quot; .<br>docker rmi pytest-with-src -f<br>docker-compose down --rmi local</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s6kN36mp0NcGw6QSfSCA8Q.png" /></figure><p>Scroll down to ‘Post-build Action’ and choose “Allure Report”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vv4IvoERZM1xt-Vutz9Ybw.png" /></figure><p>Click on ‘Save’ and the project is created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*ULkT6huWPEIGqEQpMWRLXw.png" /></figure><p>Click on “Build Now” to start the build. You can see the progress of the build in “Build history”.</p><p>Once the build is completed, we can see the stats as below —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*Tx2HU9Iq4vcJTg18UApoBg.png" /></figure><p>Note that the error(red Dot) you see are intentional so dont get panic :)</p><p>Click on “Allure Report” to see the results —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7vjuOgfGyWQ5Ncax8sik6w.png" /><figcaption>Allure main dashboard</figcaption></figure><p>You can further drill down to see testcase description, error details, screenshots etc</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eOhC24Kz48I4AV2PcVR1aQ.png" /></figure><p>Hope you enjoyed the story. Please share your feedback for improvements.</p><p>Note 1: I would recommend to setup Selenium Grid with Docker Swarm to be more scalable. You can refere <a href="https://medium.com/selenium-grid-on-gcp/pytest-selenium-grid-docker-swarm-gcp-a5834b073dc2">this</a> story for the Swarm setup.</p><p>Note 2: If you want to setup using Kubernetes, please refer <a href="https://medium.com/selenium-grid-on-gcp/pytest-selenium-grid-gcp-using-kubernetes-cluster-a22a240b013">this</a> story.</p><p>Note 3: Incase if you face permission issues Jenkins running Docker use the below commands to add Jenkins for Docker group and restart Jenkins —</p><pre>sudo usermod -a -G docker jenkins<br>sudo service jenkins restart</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32c1c4db744d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/selenium-grid-on-gcp/jenkins-pytest-selenium-grid-docker-compose-gcp-allure-32c1c4db744d">Jenkins + Pytest + Selenium Grid + Docker Compose + GCP + Allure</a> was originally published in <a href="https://medium.com/selenium-grid-on-gcp">Selenium Grid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pytest + Selenium Grid + Docker Swarm + GCP]]></title>
            <link>https://medium.com/selenium-grid-on-gcp/pytest-selenium-grid-docker-swarm-gcp-a5834b073dc2?source=rss----62ce0b3d337c---4</link>
            <guid isPermaLink="false">https://medium.com/p/a5834b073dc2</guid>
            <category><![CDATA[selenium-grid]]></category>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[pytest]]></category>
            <category><![CDATA[docker-swarm]]></category>
            <category><![CDATA[gcp]]></category>
            <dc:creator><![CDATA[Ben Jose]]></dc:creator>
            <pubDate>Tue, 11 Feb 2020 06:47:33 GMT</pubDate>
            <atom:updated>2020-02-14T08:02:17.608Z</atom:updated>
            <content:encoded><![CDATA[<p>In this story I will be executing a pytest selenium script on selenium grid with Docker Swarm. I will be manually setting up VM instances in GCP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*HxuzO57u5fIzhIACuYGvnQ.jpeg" /></figure><p>If in case you are looking for a Kubernetes cluster, please visit <a href="https://medium.com/selenium-grid-on-gcp/pytest-selenium-grid-gcp-using-kubernetes-cluster-a22a240b013">here</a>. Note that script execution using Kubernetes cluster is not very efficient compared this setup.</p><p><strong>Stage 1: Setting up the VMs</strong></p><p>Login to <a href="https://cloud.google.com/">GCP </a>and navigate to VM instances (under Compute Engine).</p><p>Click on ‘Create’ to <strong>create a VM instance</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*BvwDmpQW_aVwMCAwGj-1JA.jpeg" /></figure><blockquote>In the next window — <br> — Choose a name for the VM(I named as ‘selenium-grid1’)<br> — I am using Ubuntu machine in this story. Note that you can choose any Linux flavour, but you should be familiar the way to setup the OS. Setting up Docker and firewall in RHEL flavour is bit tricky.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*ii_jpDTMq9ea6GRJQAs84w.jpeg" /><figcaption>Choosing Ubuntu VM</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*BWALdUxsc3d90SSP5LS1sA.jpeg" /><figcaption>Creating VM instance</figcaption></figure><p>Click on ‘Create’ to start creating the VM and wait for couple of minutes to finish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*6aU3XBdS0GotiPFzNz1BXw.jpeg" /><figcaption>VM instances dashboard looks like this</figcaption></figure><p>Now create one more similar VM instance (click on ‘Create Instance’).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*GaKo9U0DzBVvFQQiQwvxIQ.jpeg" /><figcaption>VM instances dashboard looks like this after the second VM creation</figcaption></figure><p>We have now setup the VM instances (aka ‘Nodes’ in docker language ).</p><p><strong>Stage 2: Setting up Docker and Docker Swarm</strong></p><p>We need to <strong>ssh to these Nodes</strong>. For that you can click on the tiny triangle near SSH and select ‘Open in browser window’. Refer below screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*ScKMg8BDPIUfm-p3uhacSg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T8jVqpBmSA-nbMvGpC-gBA.jpeg" /><figcaption>Terminals will look like this</figcaption></figure><p>Install Docker in both the Nodes.</p><pre>curl -fsSL https://get.docker.com -o get-docker.sh<br>sh get-docker.sh<br>sudo groupadd docker<br>sudo usermod -aG docker $USER<br>newgrp docker<br>docker --version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8nyj6biuEy9QCBVIJvSUFg.jpeg" /><figcaption>After docker installation on both machines</figcaption></figure><p>Run below command on one of the Nodes to <strong>initiate Docker Swarm</strong>.</p><p>docker swarm init --advertise-addr 10.160.0.17</p><p>10.160.0.17 is the ‘Internal IP’ of the that Node. You need to replace it with your IP which you can find it on ‘VM Instances’ dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*ASqbPZOkXZ1YrJp1jmERyQ.jpeg" /></figure><p>Run below command on same node to get the token to add more managers to the swarm.</p><p>docker swarm join-token manager</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*SL4ZAA9Jy05rqInv6zlJnw.jpeg" /><figcaption>Getting Manger Token</figcaption></figure><p>Run the command on the other Node. Command will look like this —</p><p>docker swarm join --token SWMTKN-1-5cwzd1vun2lsqomomyd19h4vw3xgmdgvnx0wc9thgyosamfmro-1glrp1jzgxdb2k9o9d03ii9s8 10.160.0.17:2377</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*0vy4fcD7C_G4mvDmMpjk8Q.jpeg" /></figure><p>Below command will list all the nodes attached to the swam.</p><p>docker node ls</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TLQn9ebkJsiP9TVGWFMVAg.jpeg" /></figure><p>We are now done with Docker Swarm setup !</p><p><strong>Stage 3: Setting up Selenium Grid and download the Docker image</strong></p><p>Now lets clone a pytest selenium script to our host machine. —</p><p>git clone <a href="https://gitlab.com/benjose22/pytest_selenium.git">https://gitlab.com/benjose22/pytest_selenium.git</a></p><p>Navigate to the newly created directory .</p><p>cd ~/pytest_selenium</p><p><strong>Start Selenium Grid using Docker Stack</strong>. Please refer <a href="https://github.com/SeleniumHQ/docker-selenium#version-3-with-swarm-support">official Selenium Gihub</a> page if you are curious to know more about this YAML configuration.</p><p>docker stack deploy -c selenium-swarm-stack.yml grid</p><p>I am creating a <strong>Docker image</strong> which contain the pytest selenium script.</p><p>docker build -t pytest-with-src -f pytest.Dockerfile .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*11qOkgx2N6YzXxyWbWBUpQ.jpeg" /></figure><p>This Docker Stack creates five replicas of Chrome. You can verify it using below command —</p><p>docker service ps grid_chrome</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d2oPaMdT6AqJyUF9uaVbng.jpeg" /></figure><p>Selenium Grid setup is complete. Now time to execute the script.</p><p><strong>Stage 4: Execute the pytest script</strong>.</p><p>docker run --network=&quot;host&quot; --rm pytest-with-src --browser &quot;chrome&quot; --executor &quot;remote&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*aAfQysU2ZIVXsQQIfSbI7g.jpeg" /><figcaption>While execution window will look like this</figcaption></figure><p>Note that the errors you see are intentional so dont get panic :)</p><p>We are done now !!</p><p>Finally <strong>teardown</strong>.</p><p>Delete the newly created image —</p><p>docker rmi pytest-with-src</p><p>Delete the Docker Stack —</p><p>docker stack rm grid</p><p>Hope you enjoyed the story. Please share your feedback for improvements.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5834b073dc2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/selenium-grid-on-gcp/pytest-selenium-grid-docker-swarm-gcp-a5834b073dc2">Pytest + Selenium Grid + Docker Swarm + GCP</a> was originally published in <a href="https://medium.com/selenium-grid-on-gcp">Selenium Grid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pytest + Selenium Grid +GCP using Kubernetes cluster.]]></title>
            <link>https://medium.com/selenium-grid-on-gcp/pytest-selenium-grid-gcp-using-kubernetes-cluster-a22a240b013?source=rss----62ce0b3d337c---4</link>
            <guid isPermaLink="false">https://medium.com/p/a22a240b013</guid>
            <category><![CDATA[pytest]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[selenium-grid]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[selenium]]></category>
            <dc:creator><![CDATA[Ben Jose]]></dc:creator>
            <pubDate>Wed, 05 Feb 2020 05:08:03 GMT</pubDate>
            <atom:updated>2020-02-14T07:54:35.075Z</atom:updated>
            <content:encoded><![CDATA[<h3>Pytest + Selenium Grid + GCP using Kubernetes cluster.</h3><p>In this story I will be setting up Selenium Grid in Google Cloud Platform(GCP) using Kubernetes cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*uLdeOJne5xG5o2hzTtaQRw.jpeg" /></figure><p>Login to <a href="https://cloud.google.com/">GCP </a>and navigate to Kubernetes Engine.</p><p>Create a Kubernetes cluster. Click on “<strong>Create cluster</strong>”. Refer screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*Uzch7JUqnuSlba8PN-q-rw.png" /></figure><blockquote>— Choose a meaningful name for your cluster. I named it as “node1” (which is not a meaningful name :-P)<br> — I have created 3 nodes. More the number of nodes, better the performance but will impact on billing.<br> — I picked a Machine with 2CPUs, 7.5GB memory. As before, making the machine more powerful will impact on billing.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*MbUklwP9kmjlwLmwhRVAAQ.jpeg" /></figure><p>Once the cluster is created, connect to the cluster. Click on “<strong>Connect</strong>”.</p><p>On the next popup window. Click on “<strong>Run in Cloud Shell</strong>”.</p><p>PS: Install <a href="https://chrome.google.com/webstore/detail/ssh-for-google-cloud-plat/ojilllmhjhibplnppnamldakhpmdnibd">Chrome extension</a> for gcloud to enable keyboard shortcuts.</p><p>Try running basic unix commands to verify the host is running fine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*FDYl-aG0TKQeiiZdG2YxGA.jpeg" /><figcaption>run <strong>kubectl get nodes</strong> to get the list of nodes.</figcaption></figure><p>Thats it !</p><p>You are done with setting up Kubernetes Cluster in GCP.</p><p>Now lets clone a pytest selenium script to our host machine. —</p><p>git clone <a href="https://gitlab.com/benjose22/pytest_selenium.git">https://gitlab.com/benjose22/pytest_selenium.git</a></p><p><strong>Navigate to the newly created directory .</strong></p><pre>cd ~/pytest_selenium</pre><p><strong>Start deployment of Selenium hub</strong></p><pre>kubectl create --filename=kubernetes/selenium-hub-deployment.yaml</pre><p><strong>Start service of Selenium hub. </strong>I am using NodePort in this example.</p><pre>kubectl create --filename=kubernetes/selenium-hub-svc.yaml</pre><p><strong>Start deployment of Chrome. </strong>PS: YAML for Firefox is available in the same directory. Please make appropirate changes for firefox.</p><pre>kubectl create --filename=kubernetes/selenium-node-chrome-deployment.yaml</pre><p>Add more Chrome pods using below command.</p><p>kubectl scale deployment selenium-node-chrome --replicas=5</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*dix6e3NOgmhaeKgFp9xy0A.jpeg" /><figcaption><strong>kubectl get all</strong> will now show this result.</figcaption></figure><p>Setup the <strong>gcloud firewall</strong></p><pre>export NODEPORT=`kubectl get svc --selector=&#39;app=selenium-hub&#39; --output=template --template=&quot;{{ with index .items 0}}{{with index .spec.ports 0 }}{{.nodePort}}{{end}}{{end}}&quot;`</pre><pre>export EXTERNAL_IP=`kubectl get nodes -o jsonpath=&#39;{ $.items[0].status.addresses[?(@.type==&quot;ExternalIP&quot;)].address }&#39;`</pre><pre>gcloud compute firewall-rules create test-node-port --allow tcp:$NODEPORT</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WUQ1abtP1DBzhb-YWyxFsg.jpeg" /><figcaption>`curl <a href="http://$EXTERNAL_IP:$NODEPORT">http://$EXTERNAL_IP:$NODEPORT`</a> should show the above result.</figcaption></figure><p>I am creating a <strong>Docker image</strong> which contain the pytest selenium script.</p><pre>docker build -t pytest-with-src -f pytest.Dockerfile .</pre><p>Now it is time to <strong>execute the pytest script</strong>.</p><pre>docker run --network=&quot;host&quot; --rm pytest-with-src --browser &quot;chrome&quot; --executor $EXTERNAL_IP:$NODEPORT</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GCtQ25LRyuf4BR5CZl7HGQ.jpeg" /><figcaption>Executing the container in gcloud console</figcaption></figure><p>Note that the errors you see are intentional so dont get panic :)</p><p>We are done now !!</p><p>Finally <strong>teardown</strong>. Lets delete the gcloud firewall, docker image and kubernetes development and services.</p><pre>gcloud compute firewall-rules delete test-node-port<br>docker rmi pytest-with-src<br>kubectl delete deployment selenium-hub<br>kubectl delete deployment selenium-node-chrome<br>kubectl delete svc selenium-hub</pre><p>Hope you enjoyed the story. Please share your feedback for improvements.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a22a240b013" width="1" height="1" alt=""><hr><p><a href="https://medium.com/selenium-grid-on-gcp/pytest-selenium-grid-gcp-using-kubernetes-cluster-a22a240b013">Pytest + Selenium Grid +GCP using Kubernetes cluster.</a> was originally published in <a href="https://medium.com/selenium-grid-on-gcp">Selenium Grid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>