Edge Chromium: EdgeOption().addArguments not available

Hello, I’m trying to load a specific user profile on startup for Edge Chromium.

I tried two methods

  1. Followed article on how to do that in Chrome. Unfortunately when I tried using Edge, the EdgeOption.addArguments method is not available.

import org.openqa.selenium.chrome.ChromeOptions

ChromeOptions opt = new ChromeOptions()
opt.addArguments(‘user-data-dir=C:\Users\XXXXXXX\AppData\Local\Google\Chrome\User Data\’)
opt.addArguments(‘profile-directory=Profile 1’)

  1. I’ve also tried this method but without success.
    Using Project > settings > Desired Capabilities > WebUI > Edge Chromium and added arg [–user-data-dir=C:\Users\XXXXXXX\AppData\Local\Microsoft\Edge\User Data\, --profile-directory=Profile 1].

Does this help?

Yes, it helped. Being a novice user on Katalon and Selenium, I managed or hacked out how to use Selenium 4 (beta version) instead of the built-in Selenium 3 in Katalon. Don’t know how stable it is but at least it is working.

Instructions:
Project settings > Library management.
Add external libraries and remove built-in library

  • add selenium-server-4.0.0-beta-2.jar
  • add okhttp-3.9.1.jar
  • remove selenium-server-standalone-3.141.59.jar

In script mode, add the following

import org.openqa.selenium.edge.EdgeOptions as EdgeOptions
import org.openqa.selenium.edge.EdgeDriver as EdgeDriver
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory

EdgeOptions opt = new EdgeOptions()

opt.addArguments(‘user-data-dir=C:\Users\xxxxx\AppData\Local\Microsoft\Edge\User Data\’)
opt.addArguments(‘profile-directory=Profile 1’)

System.setProperty(‘webdriver.edge.driver’, ‘C:\Katalon_Studio_7.9.1\configuration\resources\drivers\edgechromium_win64\msedgedriver.exe’)

EdgeDriver driver = new EdgeDriver(opt)

DriverFactory.changeWebDriver(driver)

WebUI.navigateToUrl(‘https://www.google.com’)

@johleung

This might prove useful to you for your original issue.

Microsoft have published their edge chromium selenium tools:
Use WebDriver (Chromium) for test automation - Microsoft Edge Development | Microsoft Docs

That leads to a jar download that works with selenium 3 for Edge Chromium:
com.microsoft.edge : msedge-selenium-tools-java : 3.141.0 - Maven Central Repository Search

Download that and import to your katalon libary and then in your scripts.

I wanted to change the download directory but this should also work for addArguments…

import com.microsoft.edge.seleniumtools.EdgeDriver
import com.microsoft.edge.seleniumtools.EdgeOptions

WebUIDriverType executedBrowser = DriverFactory.getExecutedBrowser()

if (executedBrowser == WebUIDriverType.EDGE_CHROMIUM_DRIVER) {
    Map<String, Object> edgePrefs = new HashMap<String, Object>()
edgePrefs.put("download.default_directory", GlobalVariable.downloadsDirectory)
edgePrefs.put("download.prompt_for_download", false)
edgePrefs.put("download.directory_upgrade", true)
EdgeOptions options = new EdgeOptions()
options.setExperimentalOption("prefs", edgePrefs)
WebDriver driver = new EdgeDriver(options)
DriverFactory.changeWebDriver(driver);
}

Hope that helps in a less, as you put it, hacky way.