Automate tests with Firefox to save approval of using location for WebUI testing

I am new to automation and trying to do testing with multiple browsers. What I have is working in Chrome, but Firefox has been a bit more of an issue. I am testing logging in a website and going to a page that can use my location information to get weather data. As soon as I log in, I get a Firefox request for permission to get location. I have been trying unsuccessfully to create a separate Firefox profile that I access during testing that will allow location and save it. If I click save during testing and I don’t click to remember on log in, it will ask again when I go to the weather page and click a “Get Current” button for local date and weather data. My first image is the message I get on login FF location

Next image is my profile dictionary in Web UI Desired Capabilities in Project Settings FF Property Args

Next is the code I am using for login

Finally I have the code I am trying to use to get the created Firefox profile that is copied from previous posts FF Profile - Copy

Any assistance is greatly appreciated

@Russ_Thomas
@Brandon_Hein
@bionel
@kazurayam

Any suggestion guys ? I don’t have much experience on this.

One thing to try, that I just recently noticed. The following does not work:

WebDriver driver = new FirefoxDriver(...);
DriverFactory.changeWebDriver(driver);
WebUI.openBrowser(...);

What this will do is:

1.) new FirefoxDriver(...) will open a new browser instance and driver, with your custom capabilities/options.
2.) DriverFactory.changeWebDriver(driver) will correctly give KS a reference to your custom driver.
3.) WebUI.openBrowser(...) <- this is the problem. This will close your custom browser/driver, and open a new one, without your custom settings.

I’m not exactly sure of your order of operations, but it looks like this may be causing you problems. If instead of calling WebUI.openBrowser(...) you call:

WebUI.navigateToUrl(...)

… you’ll notice that your custom browser/driver remains active, and KS uses that instead.

2 Likes

@Brandon_Hein Thank you for the response. I am coming back to this after being on another project. I went through and do not seem to have openBrowser and do have navigateToUrl, but I still seem to have the location access question every time I run in Firefox. Wasn’t sure if you knew of any other work around to that it save the permission to have access to my location?

The following StackOverflow issue tells that you can create a firefox driver which is “geo.enabled” prerference is set “true”.

@tgeabler

Could you share your Application Under Test’s URL which challenges “Allow Location Access”?

@kazurayam I am actually working on it in our Dev environment behind our company firewall so you will not be able to access it. Is there a way to set profile preferences with Katalon rather than creating a firefox driver?

@kazurayam Would the method presented in this thread work for what I am trying to do? How to set Firefox -profile in Katalon Studio 6.2.1

I don’t know.

Browsers (FF, Chrome, …) have so many preferences/properties/desired capabilities to solve so many customisation requirements that there is no comprehensive resource that tells you for-what and how. All we can do is to make Google-searchs a lot for know-how fragments, and try them yourself against your Application Under Test. That is the reason why I asked you if your AUT is accessible for me. Unfortunately your AUT is not public. Ok, then. Please help yourself.

@kazurayam Thank you for all your assistance and patience with me as I am new to all this automation work and working with software in general. Even if I provided my URL it wouldn’t work outside of my company. I will keep working on this on my end and reach out if I have any more issues or reach a solution. Thank you again.