Here's a small program that doesn't seem to close the last tab.
from marionette_driver.marionette import Marionette
client = Marionette("localhost", socket_timeout=30, port=proc_port)
client.start_session()
client.set_window_size(1024,768)
client.close()
that will not close the last tab but if there are multiple tabs it will close one.
Calling client.quit() will throw an error.
How do I close the last tab/ window from the python marionette client?
I'll go ahead and answer this one myself. After a lot of crashes, I searched down the crash string and it lead me to this file on the mozilla development network for the mariontte.py
Looking through the code I saw these lines
I kept getting the crash
quit() can only be called on Gecko instanced launched by Marionette
then I looked around and saw the force quit option so I tried that and it seems to kill the last Firefox window.
Maybe in the future Firefox team can fix this or I might be using the API wrong.
If you have more than 1 tab open you can close it by switching to that window handle and calling client.close() on that window handle.
If you only have one tab left open, that no longer works and for me I had to call
to close the last window and exit.