To maximize the Browsing Window while using google-chrome-headless you need to replace:
add_argument --start-maximized
With:
add_argument window-size=1400,600
Alternative
The command Maximize Browser Window
may still not be working in robotframework.
This is a known issue with robotframework for quite some time now. We have discussed this issue within the discussion "Maximise browser Window" keyword not working in IE,FF and chrome.I am using selenium2Library at length. However there is a work around provided by @srib4ufrnd
as follows:
- Step 1: When selenium2library is installed in robot frame work , the selenium2library will create the python files (these python files contains the python code for selenium keywords) in the path
C:\Python27\Lib\site-packages\Selenium2Library\keywords
- Step 2: Among these python files the code for keyword
Maximise browser window
is present in the python file with name browsermanagement.py
Step3: The code for Maximise browser window is not working.
def maximize_browser_window(self):
"""Maximizes current browser window."""
self._current_browser().execute_script("if (window.screen) { window.moveTo(0, 0); window.resizeTo(window.screen.availWidth, window.screen.availHeight); }")
Step 4: Copy the above file and save it with another name for backup sake. This will help us if we need to revert back quickly incase of any issues.
Step 5: Now replace the above mentioned code in the "_browsermanagement.py" file with the following code.
def maximize_browser_window(self):
"""Maximizes current browser window."""
self._current_browser().maximize_window()
- Step 6: Save the file
_browsermanagement.py
after editing.
Note: Ensure you are saving the file in proper encoding technique using only "notepad" which comes as deafult with windows to edit and save the file.
- Step 7: Execute your test which can now perform the same operation of the keyword Maximise browser window.
Reference
You can find a couple of relevant discussions in: