Web url checking from browser network using Katalon Studio


Katalon studio is a very easy to manage automation testing for web, mobile or windows application. On web automation testing sometime we need to check a url which will be redirected to another url. So we need to trace browser all network request to find out the source url before redirection. With katalon we could implement this very easily. Here I am giving sample code how we could manage it.



System.setProperty('webdriver.chrome.driver', DriverFactory.chromeDriverPath)

BrowserMobProxy proxy = new BrowserMobProxyServer()

proxy.start(8088)

DesiredCapabilities caps

WebDriver driver

ChromeOptions option = new ChromeOptions()

proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT)

// get the Selenium proxy object
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy)

caps = new DesiredCapabilities()

caps.setCapability(CapabilityType.PROXY, seleniumProxy)

caps.setBrowserName('chrome')

option.merge(caps)

proxy.newHar('proxyServer')

//Enable headless browser checking
option.addArguments("--headless", "--disable-gpu", "--window-size=1920,1200","--ignore-certificate-errors");

driver = new ChromeDriver(option)

driver.get('https://ziyedbd.wordpress.com')

DriverFactory.changeWebDriver(driver)

WebUI.delay(2)

//Your all testing code goes in a test case and called on below lines
WebUI.callTestCase(findTestCase('testcase_file_location'), [:], FailureHandling.STOP_ON_FAILURE)

Har har = proxy.getHar()

File harfile = new File('Data Files/network.har')

har.writeTo(harfile)

def jsonSlurper = new JsonSlurper()

def data = jsonSlurper.parse(new FileReader(harfile))

data.log.entries.each({ def entry ->
    def request = entry.request

    if (request) {
        URL url = new URL(request.url)
	//Will print all network url	
	println(url)
		
    }
})

proxy.stop()

To have all codes including import items, please go to this link of my github account

Docker essential commands


Docker makes a developer life so easy. It helps to build and ship the project easily with all dependencies and environments while deployment. It also helps the developer machine to be lightweight from all project dependencies to manage it without installation.

Docker Version

docker version

Check all installed Images

docker image ls

Download an image

docker pull [IMAGE]

Retag existing image

docker image tag nginx ziyed/nginx

Upload to dockerhub

docker image push ziyed/nginx

If denied, do

docker login

Remove all images

docker rmi $(docker images -a -q)

Create and run a container in foreground

 docker container run -it -p 80:80 nginx

Create and run a container in background

docker container run -d -p 80:80 nginx

Give a naming to Containers

docker container run -d -p 80:80 --name nginx-server nginx

Check all running containers



docker container ls

docker ps -a 

Stop a Container

docker container stop [ID or Name]

Stop all running container

docker stop $(docker ps -aq)

To remove a running container use force(-f)

docker container rm -f [ID or Name]

Remove multiple containers

docker container rm [ID] [ID] [ID]

Check container error logs

 docker container logs [NAME]

View info on container

 docker container inspect [NAME]

View specific container property

docker container inspect --format '{{ .NetworkSettings.IPAddress }}' [NAME]

Performance stats (cpu, mem, network, disk, etc)

docker container stats [NAME]

Use exec to edit or access to container

docker container exec -it [NAME] bash

Network list

docker network ls

Network Inspect

docker network inspect [NETWORK_NAME]

Create network

docker network create [NETWORK_NAME]

Create container on network

docker container run -d --name [NAME] --network [NETWORK_NAME] nginx

Connect/disconnect existing container to/from network

docker network connect [NETWORK_NAME] [CONTAINER_NAME]
docker network disconnect [NETWORK_NAME] [CONTAINER_NAME]

Build an image from Dockerfile

docker image build -t [REPONAME] .

Run a container with volume mount from directory

docker container run  -p 80:80 -v $(pwd):/usr/share/nginx/html nginx

To run a docker compose file

docker-compose up

Run in background

docker-compose up -d

To cleanup

docker-compose down