Error when I try to run my script in Firefox with a specific non anonymous profile

Hello community!!!

I am trying to open my test case with a non anonymous profile of Firefox, using the code I found here, but I get error.

Here is my code:

import org.openqa.selenium.By
import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxOptions
import org.openqa.selenium.firefox.FirefoxProfile
import org.openqa.selenium.firefox.ProfilesIni

import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.driver.WebUIDriverType
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

WebUI.openBrowser('')
WebUIDriverType executedBrowser = DriverFactory.getExecutedBrowser()
switch(executedBrowser) {
	case WebUIDriverType.FIREFOX_DRIVER:
		ProfilesIni profile = new ProfilesIni()
		FirefoxProfile FF = profile.getProfile("default")
		FirefoxOptions options = new FirefoxOptions().setProfile(FF)
		System.setProperty('webdriver.gecko.driver', DriverFactory.getGeckoDriverPath())
		WebDriver driver = new FirefoxDriver(options)
		WebUI.closeBrowser()
		DriverFactory.changeWebDriver(driver)
		break
}
WebUI.navigateToUrl(GlobalVariable.artistURL)

And here is the error:

Test Cases/MyCaseName FAILED.
Reason:
org.openqa.selenium.WebDriverException: Unexpected value for profile: null
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'MYPCNAME', ip: 'MyIP', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_282'
Driver info: driver.version: unknown
	at org.openqa.selenium.firefox.FirefoxOptions.setCapability(FirefoxOptions.java:328)
	at org.openqa.selenium.firefox.FirefoxOptions.setProfile(FirefoxOptions.java:224)
	at org.openqa.selenium.firefox.FirefoxOptions$setProfile.call(Unknown Source)
	at MyCaseName.begin(MyCaseName:109)
	at MyCaseName.artistURL(MyCaseName:52)
	at MyCaseName.beginChoice(MyCaseName:34)
	at MyCaseName.run(MyCaseName:18)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:442)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:433)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:412)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:404)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:281)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1645273475588.run(TempTestCase1645273475588.groovy:25)

Any idea why is this happening?

The code you exposed to us does not contain begin, artistURL, beginChoice.
This implies that the error was thrown by some other code.
You are looking at wrong point.

No, I just change the WebUI.navigateToUrl and removed what it does after navigates to this URL… I think the problem is here: org.openqa.selenium.WebDriverException: Unexpected value for profile: null and here Driver info: driver.version: unknown. But I don’t know what to do with this…

I tried the code you exposed to us. It worked fine without any error.

This implies your original code (which is different from what you exposed to us) has something wrong, but others can not see what. I have no more comment.

Okay, I isolated the code into an other, new test case, and it gives me error again…

Here is my code as it is now:

import org.openqa.selenium.WebDriver
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxOptions
import org.openqa.selenium.firefox.FirefoxProfile
import org.openqa.selenium.firefox.ProfilesIni

import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.driver.WebUIDriverType
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI


WebUI.openBrowser('')
WebUIDriverType executedBrowser = DriverFactory.getExecutedBrowser()
switch(executedBrowser) {
	case WebUIDriverType.FIREFOX_DRIVER:
		ProfilesIni profile = new ProfilesIni()
		FirefoxProfile FF = profile.getProfile("default")
		FirefoxOptions options = new FirefoxOptions().setProfile(FF)
		System.setProperty('webdriver.gecko.driver', DriverFactory.getGeckoDriverPath())
		WebDriver driver = new FirefoxDriver(options)
		WebUI.closeBrowser()
		DriverFactory.changeWebDriver(driver)
		break
}
WebUI.navigateToUrl('https://wwww.google.com')
WebUI.waitForPageLoad(60)

And here is the error:

Test Cases/Just a test case FAILED.
Reason:
org.openqa.selenium.WebDriverException: Unexpected value for profile: null
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '***', ip: '***', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_282'
Driver info: driver.version: unknown
	at org.openqa.selenium.firefox.FirefoxOptions.setCapability(FirefoxOptions.java:328)
	at org.openqa.selenium.firefox.FirefoxOptions.setProfile(FirefoxOptions.java:224)
	at org.openqa.selenium.firefox.FirefoxOptions$setProfile.call(Unknown Source)
	at Just a test case.run(Just a test case:24)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:442)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:433)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:412)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:404)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:281)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1645276899755.run(TempTestCase1645276899755.groovy:25)

The script worked and I think I found what was wrong… For some reason, I had to create a second Firefox profile. It doesn’t work if Firefox has only one profile and in fact the default one!!! Have you noticed that too?

No. I noticed another point.

This URL is wrong.
wwww should be www.
Not 4 w but 3.

You should remove 2 lines:

The above 2 lines does not make sense in this context.

1 Like

Okay I changed it and it is working… But, only with my new created profile. If I run it using by default Firefox profile FirefoxProfile FF = profile.getProfile("default") script keep saying Running without do something. If I run it using my new created profile FirefoxProfile FF = profile.getProfile("For Katalon") it is working!!!

And I wonder, does this have to do with the default profile? Or because my default profile is signed in as Firefox account?

The default Firefox profile is not necessarily named with a string “default”.

For example, on my PC, the default Firefox profile is named with a string “kazurayam”.

Oh okay… In my case named “default” and it is signed in as a Firefox account!!! And I think maybe this is the reason why script can’t finish with my default profile…

Perhaps, the default profile doesn’t have any string name.

Υes this is really possible but if I rename it, doesn’t get one? Because I also tried to rename it to “Simos Sigma” and then I tried the script with this new name FirefoxProfile FF = profile.getProfile("Simos Sigma") but again, nothing. Keep saying Running without do something.

Sorry, I do not know much about firefox.

Okay thank you very much for your time!!!

What happens if you set “For Katalon” as the default?

I tried that too… And still, default (by the name) profile keep saying Running and after some time gives this error:

Test Cases/*** FAILED.
Reason:
java.lang.OutOfMemoryError: Java heap space
	at org.openqa.selenium.io.Zip.zip(Zip.java:46)
	at org.openqa.selenium.firefox.FirefoxProfile.toJson(FirefoxProfile.java:362)
	at org.openqa.selenium.firefox.FirefoxOptions.asMap(FirefoxOptions.java:364)
	at org.openqa.selenium.MutableCapabilities.<init>(MutableCapabilities.java:48)
	at org.openqa.selenium.firefox.FirefoxDriver.dropCapabilities(FirefoxDriver.java:257)
	at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
    ...
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:442)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:433)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:412)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:404)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:281)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)

I also noticed that as much as I load with addons the new profile (For Katalon) the longer it takes to open and run the script!!! Maybe the default (by the name) profile it’s late to open because it has to load too many things? And in the end it gives this error due to timeout or something?