1

I need to hide browser do some actions and then open browser in selenium python?

some code:

driver = webdriver.Chrome('./chromedriver') # connecting driver

options.add_argument('headless') # that's how I hide browser

driver = webdriver.Chrome(chrome_options=options)

driver.get("google.com") 

and now I need to open browser for user

3
  • 1
    Hi it would be of help if you could proved a minimal reproducible example. Also consider reading the How to Ask page, to increases chance getting a useful answer. Commented Apr 15, 2020 at 20:54
  • as I know Selenium has access only to part which displays page but not to menu, border, and other element in window. You may need other tools to minimize and maximize window - ie, PyAutoGUI Commented Apr 15, 2020 at 21:19
  • @DipakBachhav Edited with example Commented Apr 15, 2020 at 21:37

2 Answers 2

2

You wont able to do it with your current code as your have initiated chromedriver in headless mode and your browser simulation program that does not have a user interface.Also your url is not corrent in above example. Try below code

options = webdriver.ChromeOptions()
options.add_argument("--headless")
driver = webdriver.Chrome(executable_path=r" path of chromedriver.exe",chrome_options=options)
driver = webdriver.Chrome(executable_path=r"C:\New folder\chromedriver.exe")
base = "https://www.google.com/"
driver.get(base)

Output:

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

If I understood u rigth u use one more chromedriver to do it. The aim is: I launch invisible browser it add to card product, fill some date and when card filled I want to open browser for filling secure code(3dc) its 4-6 signs which send to user from bank and user will fill it manually. User need to see only window to fill code. If I copy link on window with secure code I get an error cuz I don't generate cookie or kinda of this
Yes use webdriver.Chrome() to reset from headless = True to headless = False @Hush
0

Another example

import time

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("--headless")
driver = webdriver.Chrome(options=options)
headless_page = "https://www.google.com/"
driver.get(headless_page)
url = driver.current_url
print(url)  # print headless url


time.sleep(2)

driver = webdriver.Chrome()  # reset headless to false
driver.get(url)  

1 Comment

thks but I need to open page where actions occured. if I open link in new tab/browser I got HTTP Status 405 error. It need to be in one browser cuz that's bank page and they are trying to protect themself. May be it is possible to do smthing like drive.show() I don't know(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.