Hi Dave,
First I tried to create and save the profile:
*** Settings ***
Library SeleniumLibrary
Library Browser
#*** Tasks ***
#Click Element When Visible xpath:id=“accept-choices”
*** Variables ***
${URL}= http://www.some_blah_blahwebsite.com
${Web_Browser}= firefox
${Executable_Path_To_Chrome}= C:\Program Files\Google\Chrome\Application\chrome.exe
${Executable_Path_To_Firefox}= C:\Program Files\Mozilla Firefox\firefox.exe
${EMAIL_INPUT_FIELD}= name:loginformat
${EMAIL}= eager_to_learn@emailaddress.com
${NEXT_BUTTON}= id:Button9
${PASSWORD_FIELD}= id:password_fld
${PASSWORD}= qwerty
${IDENTITY}= xpath://*[@id=“id_verify”]
${VERIFY_BUTTON}= id:idSubmit_REMEMBER
${CHECKBOX_REMEMBER}= name:REMEMBER
*** Keywords ***
Practicising SaveProfile
SeleniumLibrary.Open Browser ${URL} ${Web_Browser} ${Executable_Path_To_Firefox}
Maximize Browser Window
Sleep 60s
*** Test Cases ***
SaveProfile Test for Firefox
New context
SeleniumLibrary.Open Browser ${URL} ${Web_Browser} ${Executable_Path_To_Firefox}
Maximize Browser Window
Sleep 10s
#New Page ${URL}
# Perform login
#Fill Secret ${EMAIL_INPUT_FIELD} ${EMAIL}
Input Text ${EMAIL_INPUT_FIELD} ${EMAIL}
#Fill Secret ${PASSWORD_FIELD} ${PASSWORD}
#Input Password ${PASSWORD_FIELD} ${PASSWORD}
Sleep 10s
Click Button ${NEXT_BUTTON}
Sleep 10s
Input Password ${PASSWORD_FIELD} ${PASSWORD}
Sleep 10s
Click Button ${NEXT_BUTTON}
Sleep 20s
Click Element ${IDENTITY}
Sleep 40s
#CLICK the sms field
Click Button ${VERIFY_BUTTON}
Sleep 20s
Select Checkbox ${CHECKBOX_REMEMBER}
Sleep 20s
Click Button ${NEXT_BUTTON}
Sleep 40s
# Save storage to disk
${state_file}= Save Storage State
# Create new context with saved state
# No new page is launched in my case with these codes below
New context storageState=${state_file}
New Page ${URL}
#SeleniumLibrary.Open Browser ${URL} ${Web_Browser} ${Executable_Path_To_Chrome}
#Maximize Browser Window
Sleep 60s
The profile that is created in the D:\EagerToLearn\MY_LEARNING\PycharmProjects\RobotFWTutorial\Results\browser/browser/state folder in .json format like this:
+++++++++++++++++++++++++
{
“cookies”: ,
“origins”:
}
+++++++++++++++++++++++++
Then from searching I found: that if we type in Firefox: about:support
It shows Profile Folder:
C:\Users\EagerToLearn\AppData\Roaming\Mozilla\Firefox\Profiles\cjakdash5235x.EagerToLearn_test_Profile\sessionstore-backups
It has three files:
- previous.jsonlz4
- upgrade.jsonlz4-20231211174248
- recovery.jsonlz4 – seems to have more data (needed for my task to accomplish) than previous.jsonlz4
I copied them to a directory and referred them in my test but seemingly no luck.
I am trying this code but it does not launch the firefox with the profile:
*** Settings ***
Library SeleniumLibrary
Library Browser
*** Variables ***
${URL}= http://www.some_blah_blahwebsite.com
${WEB_BROWSER}= firefox
#I tried these different ways to reach Firefox profile for the variable: ${ff}
#${FF_PROFILE_DIR_FOR_FIREFOX}= C:\Users\EagerToLearn\AppData\Local\Mozilla\Firefox\Profiles
#${ff}= C://Users//EagerToLearn//AppData//Roaming//Mozilla//Firefox//Profiles//cjakdash5235x.EagerToLearn_test_Profile
#${ff}= D:\EagerToLearn\MY_LEARNING\PycharmProjects\RobotFWTutorial\Resources\RESOURCES_FOR_some_blah_blahwebsite\PROFILES\recovery.jsonlz4
#${ff}= D://EagerToLearn//MY_LEARNING//PycharmProjects//RobotFWTutorial//Resources//RESOURCES_FOR_some_blah_blahwebsite//PROFILES//recovery.jsonlz4
${ff}= “D://EagerToLearn//MY_LEARNING//PycharmProjects//RobotFWTutorial//Resources//RESOURCES_FOR_some_blah_blahwebsite//PROFILES//recovery.jsonlz4”
*** Keywords ***
LAUNCH some_blah_blahwebsite WEBSITE
SeleniumLibrary.Open Browser ${URL} ${WEB_BROWSER} ff_profile_dir=${ff}
Maximize Browser Window
SeleniumLibrary.Go To ${URL}
Sleep 60s
*** Test Cases ***
LAUNCH some_blah_blahwebsite WEBSITE TEST
LAUNCH some_blah_blahwebsite WEBSITE
Then I get this exception:
AttributeError: ‘FirefoxProfile’ object has no attribute ‘“D://EagerToLearn//MY_LEARNING//PycharmProjects//RobotFWTutorial//Resources//RESOURCES_FOR_some_blah_blahwebsite//PROFILES//recovery.jsonlz4”’
I wonder is there some code that can launch firefox or any browser with its saved profile.
Sincere Regards
EagerToLearn