Reputation: 75
I've set layout.css.devPixelsPerPx in Firefox to be 0.9 (open a new tab, write "about:config" & hit Enter), since I want the browser to be opened with certain level of zoom aspect. It is working fine, when I'm opening the browser manually.
But when I run a robot script, it opens the browser with zoomed in instead of the one, already set above.
So far I've tried following options, apart from above - 1. Tried using Firefox extension, which set default zoom level, but the browser opened by Geckodriver, doen't have that extension available. 2. Run Cntrl+- to zoom out, but as soon as the url changes, the zoom is reset to 100% 3. I can have the Browser open with a command (which has the correct zoom level set). Is there a way, I can ask Robot to use the existing instance of browser than opening new one?
How can I have the Robot open the Firefox browser with certain level of zoom?
Upvotes: 0
Views: 885
Reputation: 20047
The reason why you don't see the setting effective when you run the script is because Selenium creates a new profile when it starts a browser.
Any changes you do in your browser, any extensions you add, are stored in your user's profile. Selenium uses a clean/vanilla (as in: having the default settings) profile so your testing environment is always clean - not influenced by customizations, extensions, cached resources you may have added in your daily work.
If you want to have a particular setting changed in your Selenium browser session, under Firefox with Robotframework - you're "in luck" :). The SeleniumLibrary that comes with it supports starting the browser with a precreted profile - see the documentation, the Open Browser keyword - it has an argument ff_profile_dir
.
So create a FF profile with your setting set to the value you need (I don't see a reason why it won't be stored there), and pass its directory as parameter to the Open Browser
keyword. Thus when Selenium creates a browser instance, it will use this profile, with that setting effective.
Upvotes: 1