Weekly FAQs (7) - Automation Testing Solution (Part 1)

:pushpin: FAQs under this topic:
26. How to log into a webpage with cookies?
27. How to download files from an application under test to a specified folder/directory?
28. How to ignore the certificate errors when running tests in Chrome headless mode?


:point_right: See also Weekly Katalon FAQs


26. How to log in to a web page with cookies?

You can follow these steps below to log in to a web page with Cookies:

Step 1: Install the EditThisCookie extension on Chrome

bf399713-668c-4c6a-9e59-9044eddf18ad.png

Step 2: Open Chrome and navigate to a web page such as Stack Overflow - Where Developers Learn, Share, & Build Careers

Step 3: Sign in to this web page manually

Step 4: Click on the EditThisCookie extension, and find the Authentication Cookie information.

Tips: If you don’t know which cookie you should get, try to delete each of them and refresh the page to check if the logged-in account is signed out.

3fd389ca-54a0-46b2-afe8-186f3ed631f5.png

Step 5: In Katalon Studio, use the scripts below:

WebUI.openBrowser('')

WebUI.navigateToUrl('https://stackoverflow.com/questions/10340373/how-to-send-cookies-with-selenium-webdriver')

Cookie cookie = new Cookie.Builder("acct", "<<Value of cookie>>")

.domain(".stackoverflow.com")

.expiresOn(new Date(1663752309000))

.isHttpOnly(true)

.isSecure(true)

.path("/")

.build()

WebDriver driver = ((EventFiringWebDriver) DriverFactory.getWebDriver()).getWrappedDriver()

driver.manage().addCookie(cookie)

WebUI.refresh()

Step 6: To fill in the information/value in the scripts, copy the cookies in the extension by clicking on this icon:

f3f083f2-0fb8-4242-b390-1917fca9a4f4.png

Step 7: Paste what you’ve just copied into a text editor

58ec5f54-d7c5-4bb3-a313-42d50dfbd630.png

Step 8: Find out the corresponding information to fill in the scripts such as “httpOnly“, “domain“, “secure“, “value”, etc.

The output would look like this: video.

27. How to Download files from an application under test to a specified folder/directory?

Issue:

Users want to download files from the web application under test to a specified folder instead of the default folder of the local machine.

Solution:

Define the download directory by following these steps:

  1. Open Katalon Studio > Project > Settings > Desired Capabilities > Web UI > choose your browser
  2. Input the below Desired Capabilities:
    { "prefs": { "download.default_directory": "Your download folder", "download.directory_upgrade": true, "download.prompt_for_download": false, "plugins.always_open_pdf_externally": true, "profile.default_content_settings.popups": "0", "profile.content_settings.exceptions.automatic_downloads.*.setting": "1" }, "args": [ "--no-sandbox", "--disable-dev-shm-usage" ], "useAutomationExtension": "false" }

  1. Click Apply and Close

28. How to ignore the certificate errors when running tests in Chrome headless mode?

Issue

Users cannot execute tests with Chrome headless browser. It failed with the error:” Cannot locate elements”. But when running the same tests with Chrome UI execution mode, there is no error.

Reason

It turns out that the webpage is not a self-signed certificate site yet.

Therefore, it will display a blank page when navigating to this site with a headless browser. No element can be located. We need to add some desired capabilities to ignore certificate errors in Chrome headless.

Solution

  1. Open Katalon Studio > Project > Settings > Desired Capabilities > Web UI > Chrome headless
  2. Add below desired capabilities:
  • AcceptInsecureCerts = true
  • --ignore-certificate-errors

  1. Click Apply and Close

:pushpin: Katalon Community technical FAQs are about common customer technical issues when using Katalon products. We filter these on our Helpdesk Portal 1 twice every month to help Forum users get an easy approach to the solutions to similar problems.
If you’re paid customers, you can easily submit a ticket to our dedicated Support team.

:interrobang: Want to recommend a topic? - Leave your feedback HERE!

2 Likes