Hi. I have to access an application through hybrid framework for which i have to use a particular certificate. How could I do it in the framework for different browsers? Could you provide the relevant piece of code
Instructor
09914040666 Replied on 16/07/2020
Hey,
If you have to accept the certificates, then i will request you to watch the module no. 16. The code to accept certificates is there. You just need to add that code in your open browser function
Hi Jaspreet. With selenium firefox driver i am able to open my created profile on my local system. However, it is not working when i want to use a firefox profile using remote webdriver. Please see below my code. Could you help here
caps = DesiredCapabilities.FIREFOX.copy()
profile_path = 'path to firefox profile'
profile = webdriver.FirefoxProfile(profile_path)
self.driver = webdriver.Remote(desired_capabilities=caps, command_executor='hub url here', browser_profile=profile)
Instructor
09914040666 Replied on 23/01/2021
Hey
Are you getting some error or nothing is happening?
Hi Jaspreet. I am not getting any message in the exception but it is failing when connecting to remote(FYI, i use BDD framework). Please see below the exception.
File "C:\Sambhav\venv_py3\lib\site-packages\behave\model.py", line 1329, in run
match.run(runner.context)
File "C:\Sambhav\venv_py3\lib\site-packages\behave\matchers.py", line 98, in run
self.func(context, *args, **kwargs)
File "C:\Sambhav\TestAutomationBDDFramework\BDDCommon\CommonSteps\webstepscommon.py", line 12, in i_go_to_page
webcommon.go_to(context, page)
File "C:\Sambhav\TestAutomationBDDFramework\BDDCommon\CommonFuncs\webcommon.py", line 79, in go_to
context.driver = webdriver.Remote(desired_capabilities=caps, command_executor='hub url here',browser_profile=profile)
File "C:\Sambhav\venv_py3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Sambhav\venv_py3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Sambhav\venv_py3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Sambhav\venv_py3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 208, in check_response
raise exception_class(value)
If i do not pass the profile_path i.e.
profile = webdriver.FirefoxProfile() then it creates a new profile and remote is working fine.
However, my application needs a certificate otherwise it will not open. FYI, the same profile is working fine with Firefox webdriver and I am able to open my application. i.e.
profile_path = 'path to firefox profile'
profile = webdriver.FirefoxProfile(profile_path)
self.driver = webdriver.Firefox(profile)
Instructor
09914040666 Replied on 27/01/2021
Hey,
I am attaching a file in here, request to include the additions in your code and try working with profile.
Hi Jaspreet. I am getting the same exception I sent in my last post. Is it working on your hub? I was looking at the below url yesterday:
https://github.com/mozilla/geckodriver/issues/1058
Looks like it is related to it. I am out of options right now :(
Hi Jaspreet. Could you suggest some solution?
Instructor
09914040666 Replied on 03/02/2021
Hey,
I am looking for the solution at the earliest possible.
Hey Jaspreet,
Any luck until now or some workaround?
Hey Jaspreet,
I tried another way of using the profile. I have put my firefox profile inside the container and i am referring the path to it in the argument. However, now the connection is refused if I specify the profile (if i dont specify the profile then the website opens).
Could you help on this.
Code:
options = webdriver.FirefoxOptions()
options.add_argument("-profile")
#this profile is present in the container at this path
options.add_argument("/tmp/firefox_profiles/profilename")
profile = webdriver.FirefoxProfile()
profile.set_preference("security.default_personal_cert", "Select Automatically")
profile.set_preference("security.osclientcerts.autoload", True)
profile.set_preference("security.disable_button.openCertManager", True)
profile.set_preference("security.enterprise_roots.enabled", True)
profile.set_preference("accept_untrusted_certs", True)
profile.set_preference("assume_untrusted_cert_issuer", True)
options.profile = profile
context.driver = webdriver.Remote(desired_capabilities=caps, command_executor='hub url here', options=options)
Exception:
Logs:
1614181838608 mozrunner::runner INFO Running command: "/usr/bin/firefox" "--marionette" "-profile" "/tmp/firefox_profiles/profilename" "-foreground" "-no-remote"
[GFX1-]: glxtest: libpci missing
[GFX1-]: glxtest: libEGL missing
(firefox:122): Gtk-WARNING **: 15:50:40.563: Error loading theme icon 'dialog-question' for stock: Icon 'dialog-question' not present in theme Yaru
I also read through some googling that workaround is to set marionette port to 2828. How can we set that? The below deidnt work:
#options.add_argument("--marionette-port")
#options.add_argument("2828")
Instructor
09914040666 Replied on 01/03/2021
Hey,
Please try this way, "
profile.set_preference("--marionette-port", "2828")"