How can I run selenium code without showing the browser(the code run but the browser window vouldn't show)?
You can use headless mode, which runs the Selenium script without showing the browser.
To run chrome-headless just add --headless via chrome_options.add_argument
like the following:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
#chrome_options.add_argument("--disable-extensions")
#chrome_options.add_argument("--disable-gpu")
#chrome_options.add_argument("--no-sandbox") # linux only
chrome_options.add_argument("--headless")
chrome_options.add_argument("--start-maximized");
# chrome_options.headless = True # also works
driver = webdriver.Chrome(options=chrome_options)